Click here to Skip to main content
15,745,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello .
i am trying to enter information from my texfield1 to MySql database i tried to do this using this code
String str=jTextField1.getText;
Statement s=con.createStatment();
s.execute("insert into School (Id,Name,Address)values(str,'Mark','USA')")

but after compiling complete it give me sql error in the statements .
did i make something wrong ?
thxx in advance
Updated 27-Sep-22 23:21pm
Uday P.Singh 6-Sep-11 9:30am    
what's the error message?

1 solution

Change your query as shown below -
s.execute("insert into School (Id,Name,Address)values('" + str + "','Mark','USA')")

Thanks & Regards,
Niral Soni
Share this answer
hamzah1 6-Sep-11 10:55am    
Thanks Man it's really works :D
Niral Soni 7-Sep-11 12:19pm    
Welcome !!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900