当前位置: 代码迷 >> Eclipse >> No parameters defined during prepareCall(),该怎么处理
  详细解决方案

No parameters defined during prepareCall(),该怎么处理

热度:559   发布时间:2016-04-23 12:17:16.0
No parameters defined during prepareCall()
mport java.sql.*;
import java.util.ArrayList;
import java.util.List;

import com.etc.dao.GetConnectionFactory;
import com.etc.model.Customer;

public class CustomerDAOImpl
{

  public List<Customer> selectbybirth(Date stime,Date etime )
  {
  List<Customer> list = new ArrayList<Customer>();
 
Connection conn = GetConnectionFactory.getconnection();
String sql = "select * from customer where cbirth between '?' and '?'";
Customer cm = null;

try {
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setDate(1, stime);
pstmt.setDate(2, etime);

ResultSet rs1 = pstmt.executeQuery(sql);

while (rs1.next()) {
cm = new Customer(rs1.getString(1), rs1.getInt(2),
rs1.getString(3), rs1.getDate(4));
list.add(cm);
}
pstmt.executeQuery();
return list;

} catch (SQLException e) {
e.printStackTrace();
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

}
return null;
  }
pstmt.setDate(2, etime);这个数值就没跳出来,
pstmt.setDate(1, stime);直接跳到了SQLException 的异常。求大侠帮忙看看哪里错了



------解决方案--------------------
SQL code
String sql = "select * from customer where cbirth between ? and ?";
------解决方案--------------------
探讨

SQL code
String sql = "select * from customer where cbirth between ? and ?";

中的?号不需要单引号。。。
  相关解决方案