Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes  string variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark " string variables" Watch " string variables" New topic
Author

string variables

zack chancery
Ranch Hand

Joined: Aug 19, 2004
Posts: 33
imagine i have a string variable called myString.
i want to insert the string's value into a table of my database.
i can insert fine when the string is explicit but when it is referenced there is a problem.
e.g
s.execute("INSERT INTO Table (name) VALUES ('zack')); is fine

but

s.execute("INSERT INTO Tracker (name) VALUES (myString)); is NOT fine


***ERROR***
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
***********


BEST REGARDS,
Z
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
s.execute("INSERT INTO Tracker (name) VALUES ('"+myString+"')");
[ October 04, 2004: Message edited by: David Ulicny ]

SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
zack chancery
Ranch Hand

Joined: Aug 19, 2004
Posts: 33
Outstanding!!!
Thanks David,
Z
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: string variables
 
Similar Threads
Creating a database with Sun Java Application Server 9
Problem inserting a null date into a MDB
Issue with Date insertion
derby Databse connection
ERROR: java.sql.SQLException: No data found