A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
video training course this week in the
JDBC and Relational Databases
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 (?,?,?,?,?)".
[OCA 8 Book]
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
storing date in database
oracle date between
IllegalStateException when inserting session attribute into a table
insert query working in toad and giving error in jdbc
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015