![](https://csdnimg.cn/release/download_crawler_static/87722601/bg4.jpg)
conn.setAutoCommit(false);//把自动提交修改为非自动提交。
String v_sql = 'select name from table_a where id = ? '; //嵌入绑定变量
ReparedStatement stmt = conn.prepareStatement( v_sql );
stmt.setString(1, 'xxxx' ); //为绑定变量赋值
stmt.executeQuery();
conn.commit();
}
所以,请开发人员特别注意:除非有充分的理由,否则,请确保你提交给数据库执行
的任何一句 SQL 语句都是手工绑定了变量的。