为什么我会收到不兼容的数据类型错误?
int blockSize = 100;
String city="London";
" select * from"+
"(" +
" select l.* from lottotable as l where l.city='"+city+"' and l.date< cast('"+date+"' as date) order by l.date desc " +
")" +
" order by date asc limit CONVERT("+blockSize+", SQL_INTEGER )"
错误是:
java.sql.SQLSyntaxErrorException
:操作中不兼容的数据类型:;在LIMIT,OFFSET或FETCH中的语句中[select * from(从Lottotable中选择l。*作为l,其中l.city ='London'和l.date
Derby正常关闭
更新: 表的结构很简单 LOTTOTABLE(DATE,CITY,P1,P2,P3,P4,P5); p1到p5是整数,date是date类型,city是varchar
答案 0 :(得分:1)
按照注释中的建议更改查询:
int blockSize = 100;
String city="London";
String queryText =
" select * from"+
"(" +
" select l.* from lottotable as l where l.city='"+city+"' and l.date< cast('"+date+"' as date) order by l.date desc " +
")" +
" order by date asc limit "+blockSize;