• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Callable statement : Null pointer exception

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the solution friends .
It was error in my Connection to database.

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic