#534 Closing session does not release database

2.5
closed-invalid
5
2014-08-26
2007-08-06
M Hammel
No

I don't know if this is just specific to Derby, or a general issue with closing a session. If you use the embedded JDBC driver with Derby, only one connection can be open on a Derby database at a time.

If you open a Derby database with SQuirreL using the embedded driver, closing the session does not completely release the connection to the database. In order to be able to connect to database with another application, you must completely exit SQuirreL. Closing the session should be sufficient.

Thanks...

Discussion

  • Rob Manning

    Rob Manning - 2007-08-06

    Logged In: YES
    user_id=1287991
    Originator: NO

    Derby's own tool (ij) appears to be affected by this "problem" :

    http://www.jroller.com/gmazza/entry/apache_derby_in_network_server

    You should not use the "embedded" mode if you would like to access the database from multiple JVMs. The embedded mode is designed to release the lock on the database files only when the JVM exits. Therefore, if you use the embedded mode with SQuirreL, you will need to quit SQuirreL to unlock the data files for other JVMs to use. You should use the network server mode of the derby database instead of embedded mode.

    Rob

     
  • Rob Manning

    Rob Manning - 2007-08-06
    • status: open --> closed-invalid
     
  • M Hammel

    M Hammel - 2007-08-11

    Logged In: YES
    user_id=631078
    Originator: YES

    Interesting, I wasn't aware that the JVM had to exit to completely release the "hold" on the database with the embedded driver. I didn't think that was necessary as I am able to connect to the same database with the same embedded driver with the database query tool in the Netbeans IDE and I don't have to exit the IDE in order to use SQuirreL to attach to the same database. I just have to close the connection from within Netbeans. I wonder what Netbeans is doing under the covers to accomplish this?

     
  • Rob Manning

    Rob Manning - 2007-08-11

    Logged In: YES
    user_id=1287991
    Originator: NO

    Hmmm... I'd love to know that as well. But apparently that behavior isn't intended. From this embedded driver introductory article (http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html) it states clearly that the behavior you are describing isn't allowed:

    --BEGIN--

    Embedded Derby supports multiple users in one JVM

    Derby supports multiple connections to a given database. An example of an embedded application that manages concurrent users is a Tomcat or Geronimo application server that embeds Derby. Any number of users can execute Web applications that access a database through that Web server.

    However, only one JVM may boot ("open") that database, so multiple applications running in different JVMs cannot access the same database.

    -- END --

    So I can only conclude that in your case, either :

    1. NetBeans is exploiting some internal Derby "bug" (not using JDBC but some Derby-specific library API), or,
    2. Somehow you are accessing different databases (perhaps sometimes in-memory vs. file-based) or, sometimes NetBeans is using the net driver and acting like a net server internally to allow external access from other JVMs.

    If you find that the above is not the case, I'd be interested to know that.

    Rob

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks