When does Entity Framework open and close Database Connections?

Basically it opens when a request is called and closes once the results have been disposed or consumed. You can manually open/close or use the same connection using the object context… This article has a more complete explanation – http://msdn.microsoft.com/en-us/library/bb738582.aspx (archive.org) Here is the How To on using an entity Connection – http://msdn.microsoft.com/en-us/library/bb738461.aspx (archive.org)

Is it safe to use a static java.sql.Connection instance in a multithreaded system?

is my use in static Connection object thread safe? Absolutely not! This way the connection going to be shared among all requests sent by all users and thus all queries will interfere with each other. But threadsafety is not your only problem, resource leaking is also your other problem. You’re keeping a single connection open … Read more

When to close db connection on android? Every time after your operation finished or after your app exit

I don’t know of any performance penalties in frequent closing/opening of the database (regardless of its size). I think the answer to this question also depends on what type of application is accessing the database. Do you “re-query” the database a lot? Then it seems rectified to keep it open. Do you fetch different data … Read more

How to take a backup for the ‘connection details’ in sqldeveloper?

The ‘oracle sqldeveloper’ stores all the connection details in an xml file ie. connections.xml. If you want to have a backup for the connection details, you will have to navigate to In windows XP C:\Documents and Settings\<YourUserName>\Application Data\SQL Developer\systemX.X.X.X.X\o.jdeveloper.db.connection.X.X.X.X.X.X.X\ In Windows 7 C:\Users\<YourUserName>\AppData\Roaming\SQL Developer\systemX.X.X.X.X\o.jdeveloper.db.connection.X.X.X.X.X.X.X\ and take a backup of connections.xml . Later, if you need … Read more

How do I connect to a database and loop over a recordset in C#?

@Goyuix — that’s excellent for something written from memory. tested it here — found the connection wasn’t opened. Otherwise very nice. using System.Data.OleDb; … using (OleDbConnection conn = new OleDbConnection()) { conn.ConnectionString = “Provider=sqloledb;Data Source=yourServername\\yourInstance;Initial Catalog=databaseName;Integrated Security=SSPI;”; using (OleDbCommand cmd = new OleDbCommand()) { conn.Open(); cmd.Connection = conn; cmd.CommandText = “Select * from yourTable”; using … Read more

what is java.io.EOFException, Message: Can not read response from server. Expected to read 4 bytes, read 0 bytes

The connection has failed, possibly due to a firewall idle-timeout, etc. If you don’t have your JDBC driver configured to reconnect on failure, then this error will not go away unless you open a new connection. If you are using a database connection pool (you are using one, right?), then you probably want to enable … Read more

Managing connection to redis from Python

Python uses a reference counter mechanism to deal with objects, so at the end of the blocks, the my_server object will be automatically destroyed and the connection closed. You do not need to close it explicitly. Now this is not how you are supposed to manage Redis connections. Connecting/disconnecting for each operation is too expensive, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)