This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JDBC and the fly likes Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Null Pointer Exception " Watch "Null Pointer Exception " New topic
Author

Null Pointer Exception

Krishna Kodali
Greenhorn

Joined: Feb 03, 2011
Posts: 1
This program compiled but i am getting runtime null pointer exception.

Please let me know if i am doing any thing wrong.


Output:
Exception in thread "main" java.lang.NullPointerException
at JDBCExample.main(JDBCExample.java:30)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56549
    
  14

Hmmm, I'm trying to look at your code, but the stubborn forum software has made it look all wonky. If you use CODE tags when posting code to the forums (see the FAQ at ⇒ UseCodeTags ⇐) they tell it "Hey! Keep your hands off my formatting!" and your code will look just like when you cut and pasted it into the reply. Cool, no?

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14685
    
  16

The error message tells you that the NullPointerException happens at line 30. Which line is this referring to ?

Also, although you check if "conn" is not null, you don't do anything in case "conn" is null.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Null Pointer Exception
 
Similar Threads
Accessing variable from another method
Derby Bulk Insert
JDBC/Oracle access problem
derby Databse connection
Sybase -- Insufficient information to connect to the data source