Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

oracle jdbc programming(preaparedstatement setXXX vs inline sql) 1

Status
Not open for further replies.

lovekang

Programmer
Feb 16, 2006
86
KR
case 1.
PreparedStatement pstmt = conn.getPreparedStatement();
pstmt.setString(1,"john");

case 2.
String sql = "select * from emp where user_id = '" +"john"+"'";

in the cases above, performance is segnificant ?
 
Hi

If you have to execute the SQL command more then once, prepared statements are certainly faster. But it is always a good idea to use [tt]PreparedStatement[/tt], because your second code is vulnerable to SQL injection. ( Unless you do not take care of it other way. ) By handling [tt]String[/tt]s with [tt]PreparedStatement[/tt] you reduce the possibility to run into character set mismatch problems.

Just some quickly picked ideas.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top