根据practicecode和count生成结果的实际SQL查询。由于它包含多行,我无法将其插入到数据库中 使用插入查询。请帮我这个.. ??
查询
SELECT practicecode,COUNT(id) as ccr FROM empi_ccr_export_preview WHERE delflag=0 GROUP BY practicecode
代码
public void doInsertData2(HttpServletRequest request,HttpServletResponse response, ResultSet rs92, ResultSet rs102,ResultSet rs112)
{
try {
while(rs9.next()&& rs10.next()&& rs11.next()) {
Integer t1=Integer.parseInt(rs9.getString("practicecode"));
Integer t2=Integer.parseInt(rs9.getString("ccr"));
Integer t3=Integer.parseInt(rs10.getString("optinpracticecode"));
Integer t4=Integer.parseInt(rs10.getString("lab"));
Integer t5=Integer.parseInt(rs11.getString("sourcepracticecode"));
Integer t6=Integer.parseInt(rs11.getString("doc"));
try {
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
connection3 = DriverManager.getConnection("Driver details");
String query = "INSERT INTO practice_count (Community_ID,Practice_code,CCRcount,LABcount,DOCcount) VALUES (?,?,?,?,?)";
PreparedStatement preparedStmt = connection3.prepareStatement(query);
preparedStmt.setInt(1, 101);
preparedStmt.setInt(2, t1);
preparedStmt.setInt(3, t2);
preparedStmt.setInt(4, t4);
preparedStmt.setInt(5, t6);
preparedStmt.execute();
}
catch (Exception e) {
System.err.println("Duplicate Entry Found"+e);
}
}
答案 0 :(得分:0)
try,preparedStmt.executeUpdate();