title: Java Executequery Hangs
body: <p>I'm executing a very simple SQL, that when I run in SQL Server Management Studio it's take a few seconds.
  But when I run in java using JDBC it freezes. The memory usage goes from 34MB to 280MB.</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>It hangs in the line "ResultSet rsLocal = statementL.executeQuery(StringSize);"</p>
  
  <p>I'm running this jar on Java Update 8 25, so I don't think it's version problem.</p>
  
  <p>Important information is it was running perfectly till last week and nothing was changed in the code.</p>
  
  <p>What can I do to make this work? I'm completely lost and don't know java very well.</p>
  
  <p>Thank you!</p>