首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

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

2012-09-25 
No parameters defined during prepareCall()mport java.sql.*import java.util.ArrayListimport java.u

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 ?";

中的?号不需要单引号。。。

热点排行