A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
EJB 3 in Action
this week in the
EJB and other Java EE Technologies
not able to insert values
Joined: Oct 31, 2007
Mar 26, 2008 00:57:00
i am not able to insert values in the database is the query correct ???
String query = ("INSERT INTO kdnet.users VALUES ('"+firstName+"', '"+lastName+"', '"+citiicode1+"','"+address1+"','"+state+"')"); stmt.executeUpdate(query); rset = stmt.executeQuery(query); conn.commit(); rset.close(); stmt.close(); conn.close();
Joined: Oct 23, 2005
Mar 26, 2008 05:23:00
If you have a single quote in any of those strings (John O'Conner) its going to die. Your query with PreparedStatements should then just be "INSERT INTO kdnet.users VALUES (?,?,?,?,?)".
Down Home Country Coding with Scott Selikoff
Joined: Nov 25, 2007
Mar 26, 2008 05:54:00
please list out the exact error you are getting after execution of this code.
It is sorta covered in the
JavaRanch Style Guide
subject: not able to insert values
IllegalStateException when inserting session attribute into a table
storing date in database
insert query working in toad and giving error in jdbc
oracle date between
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014