When you close your connections, do you do it in a finally block?  I'm not 
saying that this is definitely causing your problem in this case, but it 
most definitely will become a problem later.  If your sql breaks before 
closing the connection, your connection is left dangling.  Same goes for 
PreparedStatement and ResultSet objects:

for instance:

try {
         //use conn, rs, and pstmt
} catch(SQLException e) {
         .....
finally {
             if (conn != null)  try { conn.close(); } catch(Exception e) {}
         if (rs != null)    try { rs.close(); }    catch(Exception e2) {}
             if (pstmt != null) try { pstmt.close(); } catch(Exception e3) {}
}

Jake

At 04:40 PM 4/2/2002 -0500, you wrote:
>I'm running Tomcat 4.0.1 on a W2K server and connecting to SQL Server 2000
>on another W2K server on our network.
>I get a Communication Link Failure from time to time. It's not a consistant
>error (it may or may not happen). You can see a snippet of the error below.
>
>I've done some research on the error and there doesn't seem to be a
>conclusive solution to the problem or what the problem stems from.
>Some say it's a synchronization problem, others say it's the db driver,
>others say its the web server because if they restart the web server the
>problem goes away for some time before it reappears and so its a problem
>with Tomcat.
>
>The db connection I'm making  is a standard connection where a Connection
>object is created and then closed after execution from within a servlet. I'm
>not using any db pooling.
>
>Can anyone provide some insite into what is happening and how I can fix it?
>Does this have anything to do with Tomcat??
>
>Thanks,
>Scott
>
>java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Communication link
>failure
>  at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
>  at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
>  at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:2533)
>  at
>sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.ja
>va:217)
>  at
>sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPreparedStatem
>ent.java:139)
>  at MyServlet.deleteRecords(MyServlet.java:408)
>
>
>--
>To unsubscribe:   <mailto:[EMAIL PROTECTED]>
>For additional commands: <mailto:[EMAIL PROTECTED]>
>Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to