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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> 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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
> 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.
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.
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 ?
Hi cristophe:
Here is the answer:
props.put("shutdown", "false");
cheers