Andreas Hartmann wrote:
Am 27.01.10 16:35, schrieb Gintare Ragaisiene:
Hi,
I have problem with communication with my MySQL database. The problem
is no inserted records in the db after INSERT close executed. When I
connect with outside client to the same db and try to act it gives me
"Lock wait timetout exceeded; try restart transaction". I have code :
protected void manageDbData(){
try {
ServiceSelector selector = (ServiceSelector)
manager.lookup(DataSourceComponent.ROLE + "Selector");
this.datasource = (DataSourceComponent)
selector.select("humana");
Connection myConnection = this.datasource.getConnection();
Statement stmt = myConnection.createStatement();
stmt.execute("INSERT INTO email VALUES (0, '[email protected]
<mailto:[email protected]>')");
String query = "SELECT * FROM area";
ResultSet result = stmt.executeQuery(query);
System.out.println("EditNewsletters result =
"+result.getFetchSize());
Is this code executed?
stmt.close();
myConnection.close();
I'm not too familiar with JDBC, but I'd assume that the close()
statements should go into the finally clause to avoid exhaustion of
the connection pool if exceptions occur.
I can confirm this. You really need to make sure that every connection
is being closed no matter what exception happened during the connection,
because otherwise your system will be "blocked" quickly
Cheers
Michael
BTW, your question is not really related to Lenya, maybe you get
better hints on a more appropriate mailing list (e.g., on the Cocoon
user list).
-- Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]