title: Can't execute MySQL stored procedure in JDBC getting nullpointer exception
body: <p>im not sure where to go from here i have messed with my code and i still get a null pointer exception. leading me to believe that maybe my connection is messed up... anyway unsure any help would be cool.</p>
  
  <pre><code>package callassstatement;
      import java.sql.CallableStatement;
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.util.Scanner;
  
  
      public class CallAssStatement {
      private static Connection conn;
  
  
      public static void printOptions() {
  
      System.out.println("enter 1 to get employee");
      System.out.println("enter 2 to get department");
      System.out.println("enter 3 to exit program");
  
  }
  
  public static String getEmployeeMethod(String id) {
      String abc = null;
      try {
  
          CallableStatement cs = conn.prepareCall(" { call sp_GetEmployee(1)}");
  
  
          cs.setString(1, id);
          //register the OUT parameter before calling the stored procedure
           cs.registerOutParameter(2, java.sql.Types.VARCHAR);
          cs.registerOutParameter(3, java.sql.Types.VARCHAR);
          cs.registerOutParameter(4, java.sql.Types.VARCHAR);
          cs.registerOutParameter(5, java.sql.Types.VARCHAR);
  
          cs.execute();
  
          //read the OUT parameter now
          String employeeId = cs.getString(1);
          String lastName = cs.getString(2);
          String firstName = cs.getString(3);
          String departmentId = cs.getString(4);
          String startDate = cs.getString(5);
  
  
  
              abc = ("EmplyeeID: " + employeeId + " " + lastName + "," + firstName + "" + " in " 
                      + departmentId + " Department "+ ", StartDate:"+ startDate);
              return abc;
  
      } catch (SQLException ex) {
          System.out.println(ex.getMessage());
      }
      return abc;
  }
  
  public static void main(String[] args) {
  
      CandDLoader.createConn();
  
      printOptions();
      Scanner s = new Scanner(System.in);
      Scanner id = new Scanner(System.in);
  
      String input = s.nextLine();
  
  
      switch (input) {
          case "1":
              System.out.println("calling get employee");
              System.out.println(" Enter employeeID:");
              String ab = id.nextLine();
              getEmployeeMethod(ab);
              break;
          case "2":
              System.out.print("calling get department");
              break;
          case "3":
              System.out.print("exiting");
              System.exit(0);
          default:
              System.out.print("what are you trying to do");
              printOptions();
  
  
  
  
      }
      }
  </code></pre>
  
  <p>here is my connection class. </p>
  
  <pre><code>package callassstatement;
  
     import java.sql.Connection;
     import java.sql.DriverManager;
     import java.sql.SQLException;
  
  
     public class CandDLoader {
  
  
     public static Connection createConn(){
  Connection conn = null;
  try{
  
  Class.forName("com.mysql.jdbc.Driver");
  conn = DriverManager.getConnection("jdbc:mysql://localhost/timeclock", "timeclockuser", "password_1234");
      }
      catch(SQLException | ClassNotFoundException ex){}
  
  
      return conn;
      }
      }
  </code></pre>