File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null pointer exception

 
kelly devon
Ranch Hand
Posts: 78
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i sent info that i got from my form on the gui
to my db using this instruction
rs.executeQuery = "INSERT INTO Borrow VALUES("+"name", "id")");
when i do the above it gives me a null pointer exception
what am i doing wrong pls help
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That line doesn't look right. I'd expect it to look like this:

if you are using a Statement (which it looks like you might be trying to do, since you are not binding any parameters). So, given how you've written it I don't see how you can get this to compile, unless I'm missunderstanding whasst you are trying to do.
[ September 23, 2004: Message edited by: Paul Sturrock ]
 
kelly devon
Ranch Hand
Posts: 78
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kelly devon:
hi,
i sent info that i got from my form on the gui
to my db using this instruction
rs.executeQuery = "INSERT INTO Borrow VALUES("+"name", "id")");
when i do the above it gives me a null pointer exception
what am i doing wrong pls help








sorry my mistake its
rs = stmt.executeQuery("INSERT INTO Borrow VALUES("+"name","+"id")");
[ September 23, 2004: Message edited by: kelly devon ]
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this

rs = stmt.executeQuery("INSERT INTO Borrow VALUES('" + name "',' " + id + "')");

I hope name and id both are char field
and both are your variables having value of name id
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correction in previous line

rs = stmt.executeQuery("INSERT INTO Borrow VALUES('" + name + "',' " + id + "')");
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK - well the only place in that line a NullPointerException can be thrown is where a method is called on the Statement object:

I assume the Statement is null.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic