This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes  string variables 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 " string variables" Watch " string variables" New topic

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.
s.execute("INSERT INTO Table (name) VALUES ('zack')); is fine


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

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

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
Thanks David,
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: string variables
It's not a secret anymore!