第一种:不用占位符,
java.sql.PreparedStatement ps = connection().prepareStatement("select * from test where name='hello'");
java.sql.ResultSet rs = ps.executeQuery();
记录集rs有数据;
第二种:使用占位符,
java.sql.PreparedStatement ps = connection().prepareStatement("select * from test where name=?");
ps.setString(1,"hello");
java.sql.ResultSet rs = ps.executeQuery();