非常纳闷的SQL语句在oracle中执行失败,不知道为什么?
queryStr = " select * from VIP_SMGROUP where SENDDT>='"+ksrq+"' AND SENDDT <='"+jsrq+"' ";
//queryStr1 = " select * from VIP_SMGROUP ";
DBConnManager db = new DBConnManager();
Connection conn = db.getConnection("Oracle");
Statement stmt = null;
ResultSet rs = null;
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
ArrayList<SMGroupLog> smgrouplogquerylist = new ArrayList<SMGroupLog>();
while (rs.next()) {
System.out.println("有记录");
SMGroupLog smgrouplog = new SMGroupLog();
smgrouplog.setSerial_num(rs.getString(1));
System.out.println("姓名"+rs.getString(2));
smgrouplogquerylist.add(smgrouplog);
}
System.out.println("记录条数"+smgrouplogquerylist.size());
} catch (
SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
非常妖怪,字段"SENDDT"是VARCHAR2类型,变量是String类型的
使用变量queryStr的SQL语句,就是执行结果为空,而语句queryStr1对应的语句正常,实际上queryStr的SQL语句是有记录的
其语句在oracle中执行正常有结果
是什么缘故呢?一个string变量参数比较而已呀?
------解决方案--------------------日期格式不对吧
SQL code
"select * from VIP_SMGROUP where SENDDT between to_date('"+ksrq+"','yyyy-mm-dd') and to_date('"+jsrq+"','yyyy-mm-dd')"
------解决方案--------------------
------解决方案--------------------