• Post Reply Bookmark Topic Watch Topic
  • New Topic

SQL query  RSS feed

 
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+")";
 
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
 
Bartender
Posts: 2633
17
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
 
author & internet detective
Marshal
Posts: 37708
578
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.
 
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]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!