mysqlにはINVENTORYテーブルがあり、num_of_items
ユーザーがGUIテキストフィールドで指定したものnum_of_items
をmysqlの以前の存在に追加しています。次のようにJavaコードでクエリを作成しました..しかし、それは私のINVENTORYテーブルを更新していません..
try {
st2 = conn.createStatement();
rs=st2.executeQuery("select order_num,prod_name_in_order,num_of_items_in_order,cost_order from ORDER_DUP where order_num='"+ord_num+"'");
int column=rs.getMetaData().getColumnCount();
int j=0;
while(rs.next())
{
for(int i=1;i<=column;i++)
{
System.out.print(rs.getObject(i)+"\t");
product_name1 = (String) rs.getObject(2);
x1 = rs.getInt(3);
//int x=Integer.parseInt(num_of_items.trim());
}
product_name[j]=product_name1;
x[j]=x1;
j++;
System.out.println();
}
for(int k=0;k<j;k++)
st2.executeUpdate("update INVENTORY set num_of_items=num_of_items+'"+x[k]+"' where product_name='"+product_name[k]+"'"); //st2.close();
//conn.close();
System.out.printf("invy");
}
catch (SQLException e) {
System.out.printf("error in updating inventory table(YES)");
e.printStackTrace();
}
私を助けてください..私は何が間違っているわけではありません!!! ありがとう。