| Author |
nullPointerException
|
Pradeep
Ranch Hand
Joined: Sep 19, 2006
Posts: 49
|
|
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 :::::::: jdbc racle: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
Joined: Apr 14, 2004
Posts: 10336
|
|
|
What is on line 78 of DBUtils? That is where your NullPointerException is occuring.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Pradeep
Ranch Hand
Joined: Sep 19, 2006
Posts: 49
|
|
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
Joined: Apr 14, 2004
Posts: 10336
|
|
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
Joined: Sep 19, 2006
Posts: 49
|
|
|
Thanks paul
|
 |
 |
|
|
subject: nullPointerException
|
|
|