Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inserting values

 
jasr jasr
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys,
i have this question
String a=textarea.getText();
CallableStatement c=connection.prepareCall("insert into database values(a)");
c.executeUpdate();
i want to update a database with the text from a text field as shown. but i this coding gives me a syntax error . y is that please tell me how to accomplish this task.
thanks
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you are not returning anything from the statement, it would be better to use a PreparedStatement. But the real problem is you need to put the value in by using a '?'. You need to bind the variable 'a' to the statement, instead of just inserting the token into the SQL text.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"jasr jasr",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic