|
Mr. A, did you happen to find a solution to your problem?
I'm afraid I don't have an answer for you, but wanted to add a similar question, which is:
Is it better to create a single connection to a database, and essentially pass this object around your code? Or, should I create and close connections each time one is needed.
Method A:
conn = database('mydb','myuser','mypass',...);
mydata = retrieve_db_data(conn);
upload_db_data(mydata, conn);
close(conn)
Method B:
the "retrieve_db_data()" and "upload_db_data()" functions both create (and close) their own database connections.
In this very simple example I doubt it makes much difference, but is there a coding practice I should follow to make sure my real-world application doesn't hit trouble? In this, I basically have a loop that retrieves and returns data from/to the database on each iteration, so that the total number of connections made are no longer trivial.
Thanks,
Sven
"Mr. A" <ozan.akcin.nospam@mathworks.com> wrote in message <h2icj5$o9g$1@fred.mathworks.com>...
> Hello,
>
> I have a bunch of code that uses the Database toolbox and creates connections (generically, 'conn') to various databases. I thought I was quite disciplined in my coding and that I would close every connection (close(conn);) once I was done with it but I'm now finding that there are a bunch of connections left hanging (maxing out connections to the server/db).
>
> Does anyone know if there is a way of finding any/all hanging connections all in one fell swoop? I was hoping there might be a 'who*' type of function which might return all my hangning connections but I haven't found any such thing.
>
> In the meantime, I'm going through my code to ensure I have all close(conn) where they should be, but it would be helpful if there were such a utility so that I could just go through and close each connection individually. My code crawl is likely to take weeks, otherwise.
>
> Any help/advice would be appreciated.
|