aspose file tools*
The moose likes JDBC and the fly likes Callable statement : Null pointer exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Callable statement : Null pointer exception" Watch "Callable statement : Null pointer exception" New topic
Author

Callable statement : Null pointer exception

Manish Tiwari
Greenhorn

Joined: May 19, 2004
Posts: 5
Friends
This is my code:

import java.sql.*;
public class callDatabaseProcedures
{

public static void main(String args[])
{
Connection conn=null;
CallableStatement cstmt=null;
ResultSet rs=null ;
try
{
//Connection1DB class gives me connection to database.
Connection1DB db = new Connection1DB();
conn=(Connection)(db.getConnection());
System.out.println("Conection is established 1");
cstmt = conn.prepareCall("{call TESTINPARAM(?,?)}");
System.out.println("Conection "+ cstmt.toString());
cstmt.setInt(1,25);
cstmt.setString(2,"xyz");
System.out.println("Trying to Executed successfully");
cstmt.execute();
System.out.println("Executed successfully");
}
catch(Exception e)
{
e.printStackTrace();
}


}

}

Console is printing till my first System.out.println . and there is null pointer exception like this .

Conection is established 1
java.lang.NullPointerException
at callDatabaseProcedures.main(callDatabaseProcedures.java:17)

My procedure is running successfully from backend .

Can any body tell me what is the problem .

Thanks
Manish
Manish Tiwari
Greenhorn

Joined: May 19, 2004
Posts: 5
I got the solution friends .
It was error in my Connection to database.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Callable statement : Null pointer exception