c*********t 发帖数: 9 | 1 have a prepared statement:
update table set columnA = 'OK' where columnB in ?;
for example,
update table set columnA = 'OK' where columnB in (1,2,3);
===========================================================
In java code, how to pass (1,2,3) to the prepared statement?
thanks! | x***n 发帖数: 70 | 2 不是将sql语句直接当作形参么?比如:
conn = DriverManager.getConnection(DatabaseConnStr);
Statement stmt=conn.createStatement( );
num=stmt.executeUpdate(sql);
很久没用这个了,不知道是不是你问的。
【在 c*********t 的大作中提到】 : have a prepared statement: : update table set columnA = 'OK' where columnB in ?; : for example, : update table set columnA = 'OK' where columnB in (1,2,3); : =========================================================== : In java code, how to pass (1,2,3) to the prepared statement? : thanks!
| B*****g 发帖数: 34098 | 3 我知道你不是要这个,嘻嘻
columnB in (?, ?, ?)
或者问谷老师
http://www.javaranch.com/journal/200510/Journal200510.jsp#a2
【在 c*********t 的大作中提到】 : have a prepared statement: : update table set columnA = 'OK' where columnB in ?; : for example, : update table set columnA = 'OK' where columnB in (1,2,3); : =========================================================== : In java code, how to pass (1,2,3) to the prepared statement? : thanks!
| r*****l 发帖数: 2859 | 4 http://docs.oracle.com/javase/6/docs/api/java/sql/PreparedState
【在 c*********t 的大作中提到】 : have a prepared statement: : update table set columnA = 'OK' where columnB in ?; : for example, : update table set columnA = 'OK' where columnB in (1,2,3); : =========================================================== : In java code, how to pass (1,2,3) to the prepared statement? : thanks!
| c*********r 发帖数: 2733 | 5 String str =update table set columnA = 'OK' where columnB in (?,?,?);
//conn is a connection
PreparedStatement ps = conn.prepareStatement(str);
ps.setInt(1,1);
ps.setInt(1,2);
ps.setInt(1,3); |
|