Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointer exception on prepared Insert

 
Vivienne Lambe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Hope someone can help. I have been working on this for hours and cant find the problem. I have an Insert statement, but when I try to actually prepare it, I receive a null pointer exception.
I would appreciate any help with this, i have tried everything.

try {
PreparedStatement pstmt = null;
StringBuffer sbSqlUpdateServer = new StringBuffer("INSERT INTO EventLog (EVENT_DATE, EVENT_URL, DOWNLOAD_SIZE) VALUES (?,?,?)");
pstmt = connection.prepareStatement(sbSqlUpdateServer.toString());

---
Exception in thread "main" java.lang.NullPointerException
at com.quickplay.parser.CreateEventLogEntries.insertEventRow(Compiled Code)
at com.quickplay.parser.CreateEventLogEntries.getTokens(Compiled Code)
at com.quickplay.parser.CreateEventLogEntries.readLogFile(Compiled Code)
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming your connection is not null?
 
Vivienne Lambe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I verified the Connection is valid.
I think the problem is with the date field. I have tried using to_date(?, 'dd/mm/yyyy') but still the same. Column defined as "Date" in table so i'm not sure if it needs a specific type when inserting.
Thanks for your reply.
 
Vivienne Lambe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found problem, unstable connection
 
Mike Rainville
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this helps ...


PreparedStatement pstmt = null; // moved before try block

try {
/* PreparedStatement pstmt = null; moved */
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic