• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL query

 
Rahul Surati
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello i am getting error in the following code..
"INSERT into test VALUES("+jTextField1+","+jPasswordField1+")";
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

some more details would be nice (e.g. which error do you get), but I suppose there are some quotation marks missing..

I think it should look like this:

"INSERT into test VALUES('"+jTextField1+"','"+jPasswordField1+"')";


John
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it might help if you mention the column names between test and VALUES.
like: insert into table (column1, column2) values (value1, value2)

And, as John pointed out, we can be of little help when we don't know the error message.

Regards, Jan
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or better yet:
"INSERT into test VALUES(?, ?)"

A prepared statement should be used here so there can't be a SQL injection attack using the password field.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul Surati wrote:hello i am getting error in the following code..
"INSERT into test VALUES("+jTextField1+","+jPasswordField1+")";


irrespective of this use..prepared statement.........otherewise for different password ,parser have to again and again prepared for execution plan..............

[jc: fixed quotation marks]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic