文字列 qLink = "";
qLink = "INSERT INTO trackgps.queclinklogs(Supplier,NtwProtocol,IMEI,log,DBTIME)" +
"VALUES" +
"(" +
"'" + supplier + "',"+
"'" + protocol + "',"+
"'" + failedQIMEI + "',"+
"'" + failedQLog + "',"+
"'" + currentQuecTimestamp + "'" +
")," +
"(" +
"'" + supplier + "'" + "," +
"'" + protocol + "'" + "," +
"'" + QuecLinkIMEI + "'" + "," +
"'" + data2 + "'" + "," +
"'" + currentQuecTimestamp + "'" +
")";
Statement stmtLink = connQ.createStatement();
stmtLink.execute(qLink);
stmtLink.close();
文字列バイト消費 = "";
bytesconsumption = "INSERT INTO test_backoffice.carrierDataConsumption(IMEI,beginMonth,endMonth,dataConsumed,month,year) VALUES" +
"(" +
"'"+ QuecLinkIMEI + "'" + "," +
"NOW()" + "," +
"NOW()" + "," +
"'"+ totalBytesConsumed + "'," +
"MONTH(NOW())" + "," +
"YEAR(NOW())" +
") ON DUPLICATE KEY UPDATE endMonth = NOW(), dataConsumed = dataConsumed + " + totalBytesConsumed;
Statement stmtbytesconsumption;
stmtbytesconsumption = connQ.createStatement();
stmtbytesconsumption.execute(bytesconsumption);
stmtbytesconsumption.close();
文字列 qdebug = "";
qdebug = "INSERT INTO trackgps.rawdata(Module,SubModule,IMEI,listenerTime,msg)" +
"VALUES" +
"(" +
"'"+ "LISTENER TCP" + "'" + "," +
"'"+ SubMod + "'" + "," +
"'"+ identifier + "'" + "," +
"'"+ listendatetime + "'" + "," +
"'"+ msg + "'" +
")";
Statement stmtqdebug = conn.createStatement();
stmtqdebug.execute(qdebug);
stmtqdebug.close();
たった1つのJavaステートメントでこの3つの挿入を実行する方法はありますか? 3 つの実行と 3 つの終了で 3 つのステートメントを作成する代わりに?
私が持っている他の質問は、ステートメントまたはPrepareStatementsを使用する必要がありますか?