Mik Lernout
Posts: 10
Nickname: miklernout
Registered: Jan, 2003
|
|
Re: Database query using string
|
Posted: Aug 7, 2003 2:01 PM
|
|
The 'right' way to do this, is by using the following code fragment:
PreparedStatement selectStatement = con.prepareStatement("SELECT * FROM users WHERE name = ?"); selectStatement.setString(0, "userName"); ResultSet result = selectStatement.executeQuery();
This way you don't have to take care of escaping the "userName" for any special SQL - characters and you allow at the same time to let the JDBC driver make some performance optimizations by using a PreparedStatement.
|
|