aspose file tools*
The moose likes JDBC and the fly likes inserting values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "inserting values" Watch "inserting values" New topic
Author

inserting values

jasr jasr
Greenhorn

Joined: Nov 17, 2002
Posts: 3
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

Joined: Apr 23, 2002
Posts: 168
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

Joined: Mar 06, 2001
Posts: 13459

"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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inserting values