title: com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 1
body: <p>I have a problem with line <code>pstmt.setLong(1, id);</code>. I get an error that the value is not set for the parameter number 1. If I use the String SQL without the question mark, it works. Also, when I use ARM the <code>PreparedStatement</code> and <code>ResultSet</code> are not automatically closed so I have to close them, and finally doesn't seem to work either</p>
  
  <pre><code>@Override  
  public Company getCompany(long id) {  
      Connection con = ConnectionPool.getInstance().getConnection();  
      String sql = "SELECT * FROM Company WHERE ID=?";  
      //String sql = "SELECT * FROM Company WHERE ID=" + id;  
      Company company = new Company();  
      try (  
          PreparedStatement pstmt = con.prepareStatement(sql);  
          ResultSet rs = pstmt.executeQuery();)  
          {  
          pstmt.setLong(1, id);  
          if (rs.next()) { 
              company.setId(rs.getLong(1));  
              company.setCompName(rs.getString(2)); 
              company.setPassword(rs.getString(3));  
              company.setEmail(rs.getString(4)); 
          } else {  
              System.out.println("Company with ID: " + id + " could not be found\n"); 
          }  
          pstmt.close();  
          rs.close();  
      } catch (SQLException e) {  
          CouponSystemException ex = new CouponSystemException("Company with ID: " + id + " could not be retrieved\n", e);  
          System.out.println(ex.getMessage());  
          System.out.println(e);  
      }  
      ConnectionPool.getInstance().returnConnection(con);  
      return company;  
  }
  </code></pre>