• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NullPointer exception on prepared Insert

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm assuming your connection is not null?
 
Vivienne Lambe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found problem, unstable connection
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if this helps ...


PreparedStatement pstmt = null; // moved before try block

try {
/* PreparedStatement pstmt = null; moved */
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic