tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Andryc <kand...@miser.umass.edu>
Subject RE: Database Locked
Date Mon, 17 Jun 2002 19:25:09 GMT
Thanks for all your help. Maybe it is the database driver because I have
tried all the examples everyone gave me and it still is locked (shrug).

Kevin


-----Original Message-----
From: Ralph Einfeldt [mailto:ralph.einfeldt@uptime-isc.de]
Sent: Monday, June 17, 2002 01:46 PM
To: Tomcat Users List
Subject: AW: Database Locked

I don't that it's tomcat that's locking your database.

If no Exception is thrown I guess it's the driver you
are using. Unless you use a JDBCRealm, I see nothing
in your code where tomcat uses your database.

If an Exception occurs, a lock can happen, as you
don't terminate the transaction in this case.

Connection connection = DriverManager.getConnection(..);
Statement statement = null;
try {
  statement = connection.createStatement();
  boolean mInTransaction = false;

  ....

  // after First Insert/Update/Delete
  mInTransaction = true;
  // furthe update/inserts/deletes
  ...
  connection.commit();
  mInTransaction = false;
} catch (..) {

} finally {
  if (statement != null) {
    try {
      statement.close();
    } catch (SQLException sqlex) {
      sqlex.printStackTrace();
    }
  }
  if (mInTransaction ) {
    try {
      connection.rollback();
    } catch (SQLException sqlex) {
      sqlex.printStackTrace();
    }
  }
  try {
    connection.close();
  } catch (SQLException sqlex) {
      sqlex.printStackTrace();
  }
}
> -----Urspr√ľngliche Nachricht-----
> Von: Kevin Andryc [mailto:kandryc@miser.umass.edu]
> Gesendet: Montag, 17. Juni 2002 19:24
> An: Tomcat Users List
> Betreff: 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>



--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>


--
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