This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes help with a statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "help with a statement" Watch "help with a statement" New topic

help with a statement

ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
hello i hope someone can help me please
i have this statement below.
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO Cust VALUES (?, ?)");
what i want to do is get the name of the table from JTextField 1 how would i do this?
Braj Prasad

Joined: Apr 08, 2002
Posts: 16
Use the following :-
String lStrTableName = JTextField.getText();
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO " + lStrTableName + " VALUES (?, ?)");
pstmt.setString(1, Str1);//assuming a varchar column
pStmt.setString(2, Str2);
I agree. Here's the link:
subject: help with a statement
Similar Threads
Synchronization Token
Statement, ResultSet
Prepared Statement with wild card
Help with Try-Catch-Finally statement