title: getting java.lang.NullPointerException while calling sql server stored Procedure using JDBC
body: <p>i am trying to get stored procedure datas from calling database through JDBC.Here i am getting resultset=null when i execute below code,what is the mistake in my code?Please guide me.</p>
  
  <h2>stored procedure</h2>
  
  <pre><code>CREATE PROCEDURE getEmpDetails
  AS
  BEGIN 
  SELECT * FROM  Employees;
  END
  </code></pre>
  
  <p>java file</p>
  
  <pre><code> // JDBC driver name and database URL
     static final String JDBC_DRIVER =   "com.microsoft.sqlserver.jdbc.SQLServerDriver";  
     static final String DB_URL =  "jdbc:sqlserver://localhost;database=JDBCDatabase";
  
     //  Database credentials
     static final String USER = "hj";
     static final String PASS = "kalpana";
  
     public static void main(String[] args) {
     Connection con = null;
     ResultSet rs = null;
     CallableStatement stmt = null;
  
     try{
            //STEP 2: Register JDBC driver
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  
            //STEP 3: Open a connection
            System.out.println("Connecting to database...");
            con = DriverManager.getConnection(DB_URL,USER,PASS);
  
            //STEP 4: Execute a query
            System.out.println("Creating statement...");
           // stmt = conn.createStatement(); 
  
            stmt = con.prepareCall("{call getEmpDetails}");
  
            ResultSet resultSet  = stmt.getResultSet();
  
            System.out.println("resultset"+resultSet);
  
              if (resultSet.next()) {
                  // Then we use a loop to retrieve rows and column data
                  // and creates a html coded table output
                  System.out.println("&lt;table border='1' &gt;");
                  do {
                   System.out.println("&lt;tr&gt;");
                   System.out.print("&lt;td&gt;" + resultSet.getString("id") + "&lt;/td&gt;");
                   System.out.print("&lt;td&gt;" + resultSet.getString("first") + "&lt;/td&gt;");
                   System.out.println("&lt;td&gt;" + resultSet.getInt("last") + "&lt;/td&gt;");
                   System.out.println("&lt;td&gt;" + resultSet.getDouble("age") + "&lt;/td&gt;");
                   System.out.println("&lt;/tr&gt;");
                  } while (resultSet.next());
                  System.out.println("&lt;/table&gt;");
                 }
     }catch(Exception e){
         e.printStackTrace();
     }finally{
         try {
             stmt.close();
             con.close();
            // input.close();
         } catch (SQLException e) {
             e.printStackTrace();
         }
     }
  
     }
  }   
  </code></pre>