Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nullPointerException

 
Pradeep
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have CallProcedure.java file :--->


System.out.println("within fetch connection");
Connection conn = null;

String driverDetails = loadDB.getProperty("DriverDetails");
String dbIP = loadDB.getProperty("IP");
String dbPort = loadDB.getProperty("Port");
String dbSID = loadDB.getProperty("SID");
String jdbcURL = driverDetails + dbIP + ":" + dbPort + ":" + dbSID;

System.out.println("JDBC URL :::::::: " + jdbcURL);
String userName = loadDB.getProperty("UserName");
String password = loadDB.getProperty("PWD");

try {

conn = DriverManager.getConnection(jdbcURL, userName, password);
System.out.println("Connection established Succesfully : " + conn);

} catch (SQLException sqe) {
System.out.println("Not able to establish Connection.");
}


which showing following error at the time of execution


Going to load driver
Drivers Loaded Successfully.
within fetch connection
JDBC URL :::::::: jdbcracle:thin:@10.201.45.95:1521:aoncoe
Not able to establish Connection.
java.lang.NullPointerException
java.lang.NullPointerException
at DBUtils.fetchCallableStatement(DBUtils.java:78)
at CallProcedure.main(CallProcedure.java:29)

please help
[ April 23, 2007: Message edited by: pradeep malekar ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is on line 78 of DBUtils? That is where your NullPointerException is occuring.
 
Pradeep
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

On line 78 .........

public static CallableStatement fetchCallableStatement(Connection fetchConnection, String callableStatementDetails) {

CallableStatement retCallStat = null;

try {
//line 78
retCallStat = fetchConnection.prepareCall(callableStatementDetails);System.out.println("Callable statement successfully Instialized" + retCallStat);

} catch (SQLException sqe) {
sqe.printStackTrace();
System.out.println("Problems in fetching Callable Statement.");
}

return retCallStat;
}
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your connection "fetchConnection" is null.

This:

Is not a good way to handle exceptions. The SQLException will most probably be telling you something important about why a Connection cannot be established. You need to print out what that message is to help understand what is going wrong.
 
Pradeep
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic