首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java Executequery挂起

Java Executequery挂起
EN

Stack Overflow用户
提问于 2014-11-29 01:06:43
回答 1查看 1.3K关注 0票数 0

我正在执行一个非常简单的SQL,当我在SQL Server Management Studio中运行时,只需要几秒钟。但是当我使用JDBC在java中运行时,它就会冻结。内存使用量从34MB增加到280MB。

代码语言:javascript
复制
public int size() {
    int lines = 0;
    string StringSize = "SELECT COUNT(BO_Numseq) FROM dbo.BOLETO";
    try {
        Statement statementL = connection.createStatement();
        ResultSet rsLocal = statementL.executeQuery(StringSize);
        rsLocal.next();
        int size = rsLocal.getInt(1);
        resetConnexion();
        return size;
    } catch (SQLException ex) {
        Logger.getLogger(ModelTratamentoBoleto.class.getName()).log(Level.SEVERE, null, ex);
    }
    return lines;

public void resetConnexion() {
    try {

        connection = MSFConstants.controleur.getConnectionAutomat().getCnx();
        statement = connection.createStatement();
        rs = statement.executeQuery(stringCommand);
    } catch (SQLException ex) {
        Logger.getLogger(ModelTratamentoBoleto.class.getName()).log(Level.SEVERE, null, ex);
    }
}



public class ConnectionAutomat {

private Connection cnx;
private String stringConnection;

public ConnectionAutomat() {
//           System.out.println("start ConnectionAutomat");
    MSFConstants.versionBdD = "NV02.06c";
    String sysUserName = System.getProperty("user.name");
    String activeBase="Automat";
    if(MSFConstants.SWtestSandBox){
        activeBase="AutomatSandbox";
    }
        stringConnection = "jdbc:sqlserver://localhost;"
                + "databaseName="+activeBase+";user="
                + MSFConstants.user.getLogonAutomat()
                + ";password="
                + MSFConstants.user.getPassAutomat();
    }

//        System.out.println("ConnectionAutomat stringConnection " + stringConnection);
    try {
        cnx = DriverManager.getConnection(stringConnection);
//     System.out.println("ConnectionAutomat connection");
    } catch (SQLException ex) {
//              System.out.println("ConnectionAutomat erreur");
        javax.swing.JOptionPane.showMessageDialog(null,
                "Error ");
//            Logger.getLogger(ConnectionAutomat.class.getName()).log(Level.SEVERE, null, ex);
        MSFConstants.controleur.fermetureApplication();
    }




}

public Connection getCnx() {
    return cnx;
}

它挂在行"ResultSet rsLocal = statementL.executeQuery(StringSize);“

我在Java Update825上运行这个jar,所以我不认为这是版本问题。

重要的信息是,直到上周,它都运行得很好,代码中没有任何变化。

我能做些什么来让它工作呢?我完全迷失了方向,对java也不太了解。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2014-11-29 01:40:09

这似乎更多的是一个数据问题。尝试从DB端分析该表,然后再次运行代码。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27193250

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档