好的,我知道答案很简单,我会觉得很傻但是......
Java JDK 1.7,Sybase JDBC驱动程序
Code snipit:
String sql = "select <blah>
from <blah blah>
where date1 = ?
UNION
select <blah>
from <blah blah>
where date2 = ?";
Connection conn = ConnectionManager.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql);
logger.info("parmemeter count: " + stmt.getParameterMetaData().getParameterCount());
stmt.setDate(1, new java.sql.Date(date.getTime()));
stmt.setDate(2, new java.sql.Date(date.getTime()));
ResultSet rs = stmt.executeQuery();
while rs.next()) {
// the rest of the code
}
答案 0 :(得分:0)
我遇到了这个问题,this thread非常有帮助。不是工会条款会引发错误;它是您传入的日期。如果您正在使用to_date()(从您的代码段中不清楚),您需要在查询中传递一个字符串(而不是日期) 。祝你好运!