You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kevin Andryc <ka...@miser.umass.edu> on 2002/06/17 19:23:46 UTC
Database Locked
I know I have posted here before on this subject but I have tried everything
and still no luck. My problem is that after I make a connection, update the
database and exit, Tomcat still holds the database until I restart Tomcat.
Here is the code I use:
try {
Class.forname("com.hxtt.sql.dbf.DBFDriver");
Connection connection =
DriverManager.getConnection("jdbc:DBF:/C:/mydatabases", "", "");
Statement statement = connection.createStatement();
// do some SQL stuff
connection.commit();
} catch (Exception ex) {
ex.printStackTrace();
}
finally {
try {
statement.close();
connection.close();
} catch (SQLException sqlex) {
sqlex.printStackTrace();
}
}
The database does get unlocked, but only well after the program was done
executing and finished. Any help is much appreciated.
Thanks,
Kevin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Database Locked
Posted by John Gregg <jo...@techarch.com>.
In addition to what George already said, you should wrap EACH close
statement in a try/catch. Here's the way I do it:
Connection conn = null;
Statement stmt = null;
try {
// get connection, do stuff
conn.commit();
} catch (Exception e) {
if (conn != null) {try {conn.rollback();} catch (SQLException sqle){}};
// handle exception here
} finally {
// clean up after yourself
if (stmt != null) {try {stmt.close();} catch (SQLException sqle) {}};
if (conn != null) {try {conn.close();} catch (SQLException sqle) {}};
}
john
-----Original Message-----
From:
tomcat-user-return-22924-john.gregg=techarch.com@jakarta.apache.org
[mailto:tomcat-user-return-22924-john.gregg=techarch.com@jakarta.apache.
org]On Behalf Of Kevin Andryc
Sent: Monday, June 17, 2002 12:24 PM
To: Tomcat Users List
Subject: Database Locked
I know I have posted here before on this subject but I have tried everything
and still no luck. My problem is that after I make a connection, update the
database and exit, Tomcat still holds the database until I restart Tomcat.
Here is the code I use:
try {
Class.forname("com.hxtt.sql.dbf.DBFDriver");
Connection connection =
DriverManager.getConnection("jdbc:DBF:/C:/mydatabases", "", "");
Statement statement = connection.createStatement();
// do some SQL stuff
connection.commit();
} catch (Exception ex) {
ex.printStackTrace();
}
finally {
try {
statement.close();
connection.close();
} catch (SQLException sqlex) {
sqlex.printStackTrace();
}
}
The database does get unlocked, but only well after the program was done
executing and finished. Any help is much appreciated.
Thanks,
Kevin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Database Locked
Posted by Kevin Andryc <ka...@miser.umass.edu>.
I have tried that and unfortunately it doesn't help either!
Kevin
-----Original Message-----
From: Sexton, George [mailto:gsexton@mhsoftware.com]
Sent: Monday, June 17, 2002 01:29 PM
To: Tomcat Users List
Subject: RE: Database Locked
You really need to do a connection.rollback() in the catch statement. If an
exception is thrown, this will leave the record locked in sql databases.
-----Original Message-----
From: Kevin Andryc [mailto:kandryc@miser.umass.edu]
Sent: 17 June, 2002 11:24 AM
To: Tomcat Users List
Subject: Database Locked
I know I have posted here before on this subject but I have tried everything
and still no luck. My problem is that after I make a connection, update the
database and exit, Tomcat still holds the database until I restart Tomcat.
Here is the code I use:
try {
Class.forname("com.hxtt.sql.dbf.DBFDriver");
Connection connection =
DriverManager.getConnection("jdbc:DBF:/C:/mydatabases", "", "");
Statement statement = connection.createStatement();
// do some SQL stuff
connection.commit();
} catch (Exception ex) {
ex.printStackTrace();
}
finally {
try {
statement.close();
connection.close();
} catch (SQLException sqlex) {
sqlex.printStackTrace();
}
}
The database does get unlocked, but only well after the program was done
executing and finished. Any help is much appreciated.
Thanks,
Kevin
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Database Locked
Posted by "Sexton, George" <gs...@mhsoftware.com>.
You really need to do a connection.rollback() in the catch statement. If an
exception is thrown, this will leave the record locked in sql databases.
-----Original Message-----
From: Kevin Andryc [mailto:kandryc@miser.umass.edu]
Sent: 17 June, 2002 11:24 AM
To: Tomcat Users List
Subject: Database Locked
I know I have posted here before on this subject but I have tried everything
and still no luck. My problem is that after I make a connection, update the
database and exit, Tomcat still holds the database until I restart Tomcat.
Here is the code I use:
try {
Class.forname("com.hxtt.sql.dbf.DBFDriver");
Connection connection =
DriverManager.getConnection("jdbc:DBF:/C:/mydatabases", "", "");
Statement statement = connection.createStatement();
// do some SQL stuff
connection.commit();
} catch (Exception ex) {
ex.printStackTrace();
}
finally {
try {
statement.close();
connection.close();
} catch (SQLException sqlex) {
sqlex.printStackTrace();
}
}
The database does get unlocked, but only well after the program was done
executing and finished. Any help is much appreciated.
Thanks,
Kevin
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>