| Author |
nullpointer
|
kelly devon
Ranch Hand
Joined: Apr 15, 2004
Posts: 71
|
|
hi, i am trying to send info to the database from my form gui but i keep on getting a nullpointer exception from where i use my statement to send this info heres what i mean stmt.executeQuery("INSERT INTO Borrow"+"VALUES("+name+","+age+")"); pls help me out and instead of Query i tried replacing with Update same null pointer pls help wat im i doing wrong?
|
kel
|
 |
Srinivasa Raghavan
Ranch Hand
Joined: Sep 28, 2004
Posts: 1228
|
|
Check whether your are getting the connection to the DB .. Srini
|
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Its more likely the statement object ("stmt") is null. How do you create the Statement object?
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
|
check your statement object, as Paul said. And yes, please give a space between your table_name and "VALUES" keyword.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26193
|
|
Kelly, You are correct that you need to use executeUpdate. Also, as name is a string, it needs single quotes. You might consider using a prepared statement to avoid these formatting issues. This isn't the source of your problem, but it is something you will hit later.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: nullpointer
|
|
|