The moose likes JDBC and Relational Databases and the fly likes inserting values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "inserting values" Watch "inserting values" New topic

inserting values

jasr jasr

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)");
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.
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

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
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.
I agree. Here's the link:
subject: inserting values
It's not a secret anymore!