由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - a prepared statement question
相关主题
How to connect to SQL2000?some simple matters take a long long time to have a solution
Hibernate querynewbie question
Re: JDBC 处理日期的问题(日期插入数据库)在手机上怎么远程控制一个房间的灯亮灯灭?
关于Exception,CatchOpen Too Many Cursor Issue
Java call stored procedure的一个问题SCJEA resource
jdbc statement questionDesperately need help on DB2 connection through jdbc in jsp page
Re: 关于APPLET的IO问题[转载] Question 1: refresh view of database?
Database Pooling 的问题arithmetic formula in java
相关话题的讨论汇总
话题: prepared话题: columnb话题: statement话题: columna话题: ok
进入Java版参与讨论
1 (共1页)
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);
1 (共1页)
进入Java版参与讨论
相关主题
arithmetic formula in javaJava call stored procedure的一个问题
Array of vector, helpjdbc statement question
求教 Listenser for table in JavaRe: 关于APPLET的IO问题
[转载] 哪位先进用过MYSQL里面的LOCK TABLEDatabase Pooling 的问题
How to connect to SQL2000?some simple matters take a long long time to have a solution
Hibernate querynewbie question
Re: JDBC 处理日期的问题(日期插入数据库)在手机上怎么远程控制一个房间的灯亮灯灭?
关于Exception,CatchOpen Too Many Cursor Issue
相关话题的讨论汇总
话题: prepared话题: columnb话题: statement话题: columna话题: ok