Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Created May 17, 2012 06:52
Show Gist options
  • Save fukayatsu/2717075 to your computer and use it in GitHub Desktop.
Save fukayatsu/2717075 to your computer and use it in GitHub Desktop.
PreparedStatementを使う時の注意
//String sql = "SELECT * FROM user where name = '?'"; //エラー
String sql = "SELECT * FROM user where name = ?"; //OK
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, userName);
ResultSet rs = ps.executeQuery();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment