public List<ChatRecord> getChatRecords(int chatId, String chatCreateTime1,
String chatCreateTime2) {
ArrayList<ChatRecord> chatRecords = new ArrayList<ChatRecord>();
String sql = "select * from chatRecord where chatId = ? and chatCreateTime between ? and ?";
Connection conn = DBConnection.getConn();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, chatId);
pstmt.setString(2, chatCreateTime1);
pstmt.setString(3, chatCreateTime2);
rs = pstmt.executeQuery();
while (rs.next()) {
ChatRecord chatRecord = new ChatRecord();
chatRecord.setChatId(rs.getInt(1));
chatRecord.setServerName(rs.getString(2));
chatRecord.setChatContent(rs.getString(3));
chatRecord.setChatCreateTime(rs.getDate(4));
chatRecords.add(chatRecord);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBConnection.closeAll(rs, pstmt, conn);
}
return chatRecords;
}public List<ChatRecord> getRecords(int chatId, String chatCreateTime1,
String chatCreateTime2) {
return chatRecordDao.getChatRecords(chatId, chatCreateTime1, chatCreateTime2);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/plain");
int chatId = Integer.parseInt(request.getParameter("chatId"));
String time1 = request.getParameter("time1");
String time2 = request.getParameter("time2");
List<ChatRecord> chatRecords = chatRecordBo.getRecords(chatId, time1,
time2);日期是这样的格式2009-03-03这样的 数据库写的也是
String chatCreateTime2) {
ArrayList<ChatRecord> chatRecords = new ArrayList<ChatRecord>();
String sql = "select * from chatRecord where chatId = ? and chatCreateTime between ? and ?";
Connection conn = DBConnection.getConn();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, chatId);
pstmt.setString(2, chatCreateTime1);
pstmt.setString(3, chatCreateTime2);
rs = pstmt.executeQuery();
while (rs.next()) {
ChatRecord chatRecord = new ChatRecord();
chatRecord.setChatId(rs.getInt(1));
chatRecord.setServerName(rs.getString(2));
chatRecord.setChatContent(rs.getString(3));
chatRecord.setChatCreateTime(rs.getDate(4));
chatRecords.add(chatRecord);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBConnection.closeAll(rs, pstmt, conn);
}
return chatRecords;
}public List<ChatRecord> getRecords(int chatId, String chatCreateTime1,
String chatCreateTime2) {
return chatRecordDao.getChatRecords(chatId, chatCreateTime1, chatCreateTime2);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/plain");
int chatId = Integer.parseInt(request.getParameter("chatId"));
String time1 = request.getParameter("time1");
String time2 = request.getParameter("time2");
List<ChatRecord> chatRecords = chatRecordBo.getRecords(chatId, time1,
time2);日期是这样的格式2009-03-03这样的 数据库写的也是
那两个''怎么办?