Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Problem with connection to database
Replies: 3   Last Post: Jul 27, 2013 11:31 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Davide Zoccatelli

Posts: 1
Registered: 7/24/13
Problem with connection to database
Posted: Jul 24, 2013 11:36 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I need to connect to the database both from the main program and from functions. After fetching lots of data (200k records) from the database in the main program, the function is not able to connect and get data anymore. I tried to close the connection or the cursor but it's still not working.

This is the code with comments describing where the connection doesn't work anymore:

function FTestConn( )
conn1 = database('DBname', 'Name', 'psw');
isconnection(conn1)
end

And the main program:

conn1 = database('DBname', 'Name', 'psw');
isconnection(conn1) %this connection works
FTestConn() %this connection works

%fetching some data from the database
curs1 = exec(conn1, 'select min(id) from table1');
curs1 = fetch(curs1);
T = curs1.data;

%The connection in the function still works
FTestConn()

%Fetching A LOT of data from the table
curs1 = exec(conn1, 'select distinct id from table1'); %about 200000 records
curs1 = fetch(curs1);
ID = curs1.data;
isconnection(conn1) %the connection still works

%The function cannot connect to the database anymore
FTestConn() %result = 0, no connection.

Any idea on what I could try?

Thank you
Davide



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.