读书人

No parameters defined during prepar

发布时间: 2012-09-25 09:55:59 作者: rapoo

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

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

读书人网 >Eclipse开发

热点推荐