简体   繁体   English

在Solaris服务器上随机重置到SQL Server 2000的JDBC连接

[英]JDBC Connection to SQL Server 2000 reset randomly on Solaris server

I have the following method being called in a Java EE web application. 我在Java EE Web应用程序中调用了以下方法。

public static void submitToPending()
{
    Db db;
    ResultSet rs;

    try
    {
        db = new Db("Database.properties");

        rs = db.issueQuery(getDescriptorList());

        while (rs.next())
        {
            db.insertApplicationData(rs.getString("Id"));
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    finally
    {
        db = null;
        rs = null;
    }
}

This is an abbreviated snippet of code I am running to insert about 40,000 new records into a SQL Server 2000 database. 这是我正在向SQL Server 2000数据库插入大约40,000条新记录的代码的简短片段。 This code is executed from a JSP that is hosted on a Solaris 10 server in production. 此代码从生产环境中的Solaris 10服务器上托管的JSP执行。 Prior to this year, this code only had to process about 18,000 records, and it worked flawlessly. 在今年之前,该代码只需要处理大约18,000条记录,并且可以完美地工作。 This year there were some updates made and, to spare details, now processes roughly 40,000 records. 今年进行了一些更新,并且为了保留详细信息,现在可以处理大约40,000条记录。

During development I test this on the same database used in production (as the record sets do not conflict) from my Windows PC , from a Tomcat server running inside of Eclipse. 在开发期间,我在Windows PC上 (从Eclipse内部运行的Tomcat服务器)在生产环境中使用的同一数据库(因为记录集不冲突)上对此进行了测试。 Everything works correctly, and all 40,000 or so records make it to the database. 一切正常,并且所有40,000左右的记录都保存到数据库中。

When I installed the site to the production server and ran a test I noticed that over halfway through the process was failing, with the following exception message: 当我将站点安装到生产服务器并运行测试时,我注意到该过程中途失败,并显示以下异常消息:

com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed. com.microsoft.sqlserver.jdbc.SQLServerException:连接已关闭。 at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.checkClosed(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerResultSet.checkClosed(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerResultSet.next(Unknown Source) at (ClassNameOmittedToProtectTheInnocent.java:74) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(未知源)在com.microsoft.sqlserver.jdbc.jdbc.SQLServerStatement.checkClosed(未知源)在com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(未知源)在com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(未知源) .microsoft.sqlserver.jdbc.SQLServerResultSet.checkClosed(未知来源)位于com.microsoft.sqlserver.jdbc.SQLServerResultSet.next(未知来源)位于(ClassNameOmittedToProtectTheInnocent.java:74)

The SQL Server is set to unlimited simulataneous connections, unlimited timeout. SQL Server设置为无限的同时连接,无限的超时。 Assuming my code in class Db is OK (since it is working on the Windows side of things and, up until the data increase, had been performing well on the Solaris side) what are some ideas to start checking out? 假设我在Db类中的代码还可以(因为它在Windows方面正常工作,并且直到数据增加,在Solaris方面一直表现良好),有什么想法可以开始检验?

I tried tracing the SQL Server to see if something was happening with the connections, but it appears to be alive even after the stack trace is written. 我尝试跟踪SQL Server以查看连接是否正在发生任何事情,但是即使在写入堆栈跟踪之后,它似乎仍然有效。

If I can provide any additional information, please let me know. 如果我可以提供任何其他信息,请告诉我。 I'll do the best I can to help. 我会尽力提供帮助。

I'm suspicious of your setting your database and result set reference to null without closing them. 我怀疑您将数据库和结果集引用设置为null而不关闭它们。 I would explicitly close these (if you have a connection pool, closing a connection doesn't actually close it, but acts as a signal to return the connection to the pool). 我会明确关闭它们(如果您有连接池,则关闭连接实际上并不会关闭它,但会作为将连接返回到池的信号)。

I'm guessing that you're running into a resource limit such as the maximum number of open file descriptors per process, and the failure to close a result set/connection will be the source of this issue. 我猜您正在遇到资源限制,例如每个进程打开文件描述符的最大数量,并且无法关闭结果集/连接将是此问题的根源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM