Menu

Bug?

Help
marcos
2006-05-03
2013-03-27
  • marcos

    marcos - 2006-05-03

    Hi,

    I've been trying to use the library but I'm getting the next error on Mac OS X 10.3.9:

    safe_mutex: Trying to lock unitialized mutex at os0sync.c, line 602
    Java Result: 6

    Here is the code, the first time that is executed works fine but after that no more, this code is executed when the user press a JButton:

         Connection conn = null;
         try{
             conn = JDBCConnectionFactory.getConnection();
             conn.setAutoCommit(false);
            
             PreparedStatement stm = conn.prepareStatement("SELECT * FROM users WHERE login = ? AND password = ? AND status = 1");
             stm.setString(1, username);
             stm.setString(2, password);
             ResultSet rs = stm.executeQuery();
            
             if (rs.next()) {
               //Do something
             } else {
               //Do something else
             }
         } catch(Exception e) {
         }finally{
             try{
                 conn.close();
             }catch(Exception e2){
             }
         }

    I'll will apreciate any help, thanks in advance.

     
    • christophe.marchand

      First, you MUST close both ResultSet and PreparedStatement BEFORE closing connection. Declare them outside of try block and close them in finally block. This is a recommendation of JDBC, and not doing so will introduce memory leaks in mysql-je (see Memory consumption thread).

      Then, putting some traces in catch blocks may help you finding problems.

       
    • Peter Schäfer

      Peter Schäfer - 2006-05-05

      > First, you MUST close both ResultSet and PreparedStatement BEFORE closing connection. Declare them outside of try block and close them in finally block.
      > This is a recommendation of JDBC, and not doing so will introduce memory leaks in mysql-je (see Memory consumption thread).

      while this is always a good idea, it should not be strictly necessary.
      Connection.close() is supposed to release all open ResultSets and PreparedStatements. But I will have a closer look at it.

       
    • marcos

      marcos - 2006-05-05

      Hi,
      First of all thank you guys, I did what Christophe told me but the problem was still present, so I tried with the configuration parameter shutdown=false and now it is working as expected. It looks like after closing the connection, mysql embedded server shutdown itself because there were no more connections open, now I control the server shutdown.

       
    • christophe.marchand

      Hi marcos,
      I've tried to add shutdown=false to the example posted in thread "memory consumption", but I have this error : 060509 11:18:43 [ERROR] mysql_embedded: unknown variable 'shutdown=false'

      Where did you put yours ?

       
      • marcos

        marcos - 2006-05-25

        Hi cristophe:

        Here is the answer:

        props.put("shutdown", "false");

        cheers

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.