Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Another tact on Tomcat servlets question - driver specs

0 views
Skip to first unread message

dmnscrg

unread,
Dec 19, 2003, 12:06:22 PM12/19/03
to
Here is the scenario...

SQL Server 2000 database is set to allow unlimited connections. Connections are established from servlets on Redhat Linux using Tomcat 4.1.24, Sun Java 1.4.2, and Apache 2.0.47. Each servlet loads the driver, opens its own connection, performs the work, and closes the connection. Randomly, a connection is being closed or dropped as the driver error message "Object has been closed" is seen in the catalina.out log. Connection method has been tried as direct and cursor with similar results. (Thanks Joe for the suggestion)

Is there a max number of connections that the JDBC 2.2.0037 driver can create?
What can cause the "Object has been closed" message to occur? Too much network traffic? Too many connections for the driver to handle? Delayed processing of the connection.close() method from an earlier servlet?

Any other suggestions? Link to in depth driver documentation and error explanations would even be great. The docs provided with the driver are way too lacking in detail.

Joe Weinstein

unread,
Dec 19, 2003, 12:18:02 PM12/19/03
to

dmnscrg wrote:

> Here is the scenario...
>
> SQL Server 2000 database is set to allow unlimited connections. Connections are established from servlets on Redhat Linux using Tomcat 4.1.24, Sun Java 1.4.2, and Apache 2.0.47. Each servlet loads the driver, opens its own connection, performs the work, and closes the connection. Randomly, a connection is being closed or dropped as the driver error message "Object has been closed" is seen in the catalina.out log. Connection method has been tried as direct and cursor with similar results. (Thanks Joe for the suggestion)
>

Are you sure that each servlet defines all it's JDBC objects as method level
objects? If not, you may be suffering when two independent users call the
same servlet at the same time, and this is two threads operating the same
object. Unless all JDBC objects are method variables, one thread may do something
which closes an object the other thread is unwittingly sharing. For instance,
even if both threads call DriverManager.getConnection(), they are setting the
*same* variable, so both of them will use the one that the last thread sets.
Joe Weinstein at BEA

dmnscrg

unread,
Dec 19, 2003, 12:36:14 PM12/19/03
to
Are you sure that each servlet defines all it's JDBC objects as method level
objects? If not, you may be suffering when two independent users call the
same servlet at the same time, and this is two threads operating the same
object. Unless all JDBC objects are method variables, one thread may do something
which closes an object the other thread is unwittingly sharing. For instance,
even if both threads call DriverManager.getConnection(), they are setting the
*same* variable, so both of them will use the one that the last thread sets.
Joe Weinstein at BEA

They are definitely method level. Nothing is shared between servlets beyond the driver itself. Do you think the DriverManager is causing the problem when I call getConnection? That is the only class side method I am calling.

Joe Weinstein

unread,
Dec 19, 2003, 1:38:06 PM12/19/03
to

dmnscrg wrote:

No. DriverManager is bad to use in multithreaded applications, but because
it is class-synchronized so it can slow up all JDBC in the whole JVM,
but it won't cause cross-threading problems. If you show me the whole
stacktrace of the 'already-closed' exception, I might be able to create
a diagnostic...
Joe Weinstein at BEA

dmnscrg

unread,
Dec 19, 2003, 6:11:19 PM12/19/03
to
Here one of the stack traces I just received...

AccountService load: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Object has been closed.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Object has been closed.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.validateClosedState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.validateClosedState(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.validateClosedState(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.commonFetchInitialize(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.next(Unknown Source)
at com.donbest.database.AccountService.load(AccountService.java:74)
at com.donbest.database.AccountService.<init>(AccountService.java:37)
at com.donbest.util.ValidateLogin.validateWithIPAddressAlternateIP(ValidateLogin.java:141)
at SendHistory.doGet(SendHistory.java:81)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:466)
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:585)
at java.lang.Thread.run(Thread.java:534)

and here is the code segment...

public void load
(int _id)
{
clearVariables ();
try
{
Connection connection = dbs_connection.createConnection ();
if (connection == null)
{
return;
}

String query = "SELECT id,account,service,active,convert(char(19),expiration,120) " +
"FROM account_service " +
"WHERE id = ?";
PreparedStatement account_select = connection.prepareStatement (query);
account_select.setInt (1, _id);
ResultSet resultSet = account_select.executeQuery ();
if (resultSet.next ()) <<<<<<<------------------------- Exception occurs here ---------------
{
id = resultSet.getInt (1);
account = resultSet.getInt (2);
service = resultSet.getInt (3);
active = resultSet.getBoolean (4);
expiration = resultSet.getString (5);
}
resultSet.close ();
}
catch (SQLException sqle)
{
System.err.println ("AccountService load: " + sqle);
sqle.printStackTrace ();
}
}

0 new messages