这个可能是因为字段名跟between连起来了,我在plsql中试了一下,给字段和between连起来就报了同样的错误,我在程序里加了空格也不起作用

plsql中执行通过的语句为:

SELECT consumption FROM dzjc.bookUse WHERE date between(to_date('2005-01-01','yyyy-mm-dd')) and (to_date('2009-03-15','yyyy-mm-dd'))




给字段连起来的语句为:



SELECT consumption FROM dzjc.bookUse WHERE datebetween(to_date('2005-01-01','yyyy-mm-dd')) and (to_date('2009-03-15','yyyy-mm-dd'))




程序中可以通过的语句为:



String SQL = "SELECT consumption FROM dzjc.bookUse WHERE date between(to_date('"+dateCreatedStart+"' ,'yyyy-mm-dd')) and (to_date('"+dateCreatedStop+"' ,'yyyy-mm-dd'))  " ;




程序中报错的语句为:



String date = " between(to_date('"+dateCreatedStart+"' ,'yyyy-mm-dd')) and (to_date('"+dateCreatedStop+"' ,'yyyy-mm-dd'))";

String SQL = "SELECT consumption FROM dzjc.bookUse WHERE date ?  " ;

pstmt.setString(1, date);

ResultSet rs = pstmt.executeQuery() ;




黑色头发:http://heisetoufa.iteye.com/