henix / blog

some notes
0 stars 0 forks source link

PreparedStatement 设置带 IN(...) 的 SQL 参数 #12

Closed henix closed 11 years ago

henix commented 11 years ago

http://stackoverflow.com/questions/178479/preparedstatement-in-clause-alternatives 看到 http://www.javaranch.com/journal/200510/Journal200510.jsp#a2

henix commented 11 years ago

http://www.cnblogs.com/fanstatic/archive/2011/08/02/2125003.html 的 split string 方法。但需要自定义一个存储过程,也许 MySQL 有 split ?

henix commented 11 years ago

stackoverflow 上的 connection.createArrayOf 这条路不行,MySQL 似乎不支持。调用 createArrayOf 时抛出 java.sql.SQLFeatureNotSupportedException

henix commented 11 years ago

最终的方案是生成类似 IN (?,?,?,?,?) 的东西,相当于 Option 2