tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Gregg" <john.gr...@techarch.com>
Subject RE: Database Locked
Date Mon, 17 Jun 2002 17:40:33 GMT
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:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message