SQL語句層返回多個值,我想用所有這些值更新數據庫中的列這裏有什麼問題?從結果集更新數據庫
String cust_code = session.getAttribute("Cust_Code").toString();
String video_typ = session.getAttribute("video_typ").toString();
int personal_p = Integer.parseInt(session.getAttribute("personal_p").toString());
int layers_p = Integer.parseInt(session.getAttribute("layers_p").toString());
String parent_cod = session.getAttribute("parent_code").toString();
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ontube", "root", "123456");
Statement st = con.createStatement();
String personal_po = "update customers set personal_p =personal_p + '"+personal_p+"' where membership_num='"+cust_code+"' ";
String first_layer="update customers set layers_p = layers_p+'"+layers_p+"' where membership_num='"+parent_cod+"'";
int pers_points = st.executeUpdate(personal_po);
int first_lyr = st.executeUpdate(first_layer);
String layers="select membership_num from customers where parent_num='"+parent_cod+"'" ;
// i want to update all values comes from these resultset
ResultSet rs = st.executeQuery(layers);
while(rs.next()){
String names =rs.getString(1);
String update_layers = "update customers set layers_p = layers_p + '"+layers_p+"' where membership_num='"+names+"' ";
int nms = st.executeUpdate(update_layers);
什麼是錯誤? – CloudyMarble 2013-05-13 07:57:11