Hi

I have a problem with my database connection. I get a trace file when
I use my application. It say that I dont' close my db connection. So I
started to close my database connections after I have used it. After
this the performance in my application is slower. This I want to
resolve.

I have a static method that return a connection:

    public static Connection getConnection() throws Exception
    {
        return DriverManager.getConnection(connectionString);
    }

So I do like this:

Connection dbConn = H2DB.getConnection();
...
dbConn.close();


Questions:
1. DriverManager.getConnection(connectionString) <-- does this
function pool connection in any way? I thought that I always was
getting a "new" connection by using it. I ask becouse of the
performance drop then I start to close connections.

2. In my first version of my of the H2DB class I did something like
this(dbConn static member in class):
public static Connection getConnection() throws Exception
{
    if(dbConn == null)
    dbConn = DriverManager.getConnection(connectionString);

    return dbConn;
}
But this resulted in that I got broken connections. It was not
possible to use them. My plan was to always use the same connection in
my application.
Why does this not work?

3. How do I resolve the performance hit for closing the connection
without getting the trace file?

/Andreas

-- 
Andreas Henningsson

"Vanligt sunt förnuft är inte särkilt vanligt." -- Voltaire

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to