这个问题已经有两天了。尝试了我能想到的一切。非常感谢你能给我解决这个问题的任何帮助。在此先感谢。
try { // try get tx records
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection (
"jdbc:mysql://localhost:3306/brent?user=root&password=adsimysql");
Statement stmt = con.createStatement(); System.out.println("aaactivity3");
ResultSet rs = stmt.executeQuery("Select * from " + tbtx);
System.out.println("aaactivity4");
while (rs.next()) { // get tx records
dbrec = rs.getInt("trec"); // get input fields from database
dbacct = rs.getInt("tacct");
dbtxtype = rs.getInt("ttype");
dbtxno = rs.getInt("ttxno");
dbamt = rs.getDouble("tamt");
dbmed = rs.getDouble("tmed");
dbsaltx = rs.getDouble("tsaltx");
dbtxdat = rs.getInt("ttxdat");
dbxmail = rs.getInt("txmail");
dbbilldat = rs.getInt("tbilldat");
System.out.println("ApplyTX " + dbacct); // print
// try { // try write ts
//Class.forName("com.mysql.jdbc.Driver");
/*Connection con = DriverManager.getConnection (
"jdbc:mysql://localhost:3306/brent?user=root&password=adsimysql");
Statement stmt = con.createStatement();*/
PreparedStatement prest;
String updttx = "INSERT INTO "+ tbts + " (sacct, stype, srec, stxno, samt, smed, sstax, stxdat, sxmail, sbilldat) VALUES (?,?,?,?,?,?,?,?,?,?)";
//String updttx;
// updttx = "INSERT INTO "+ tbts + " (sacct, stype, srec, stxno, samt, smed, sstax, stxdat, sxmail, sbilldat) VALUES (?,?,?,?,?,?,?,?,?,?)";
prest = con.prepareStatement(updttx);
System.out.println("aaactivity5 " + dbacct);
prest.setInt(1,dbacct);
prest.setInt(2,dbtxtype);
prest.setInt(3,dbrec);
prest.setInt(4,dbtxno);
prest.setDouble(5,dbamt);
prest.setDouble(6,dbmed);
prest.setDouble(7,dbsaltx);
prest.setInt(8,dbtxdat);
prest.setInt(9,dbxmail);
prest.setInt(10,dbbilldat);
System.out.println("aaactivity6 "+ dbtxtype);
int executeUpdate = prest.executeUpdate(); // this statement is throwing SQLException
System.out.println("aaactivity7");
} // end while get tx records
} // end try get tx records and build ts file ********************************
catch(ClassNotFoundException e) {
}
catch(SQLException insertException) { System.out.println("SQLexception"+dbacct+" "+dbtxtype+" "+dbrec+" "+dbtxno+" "+dbamt+" "+dbmed+" "+dbsaltx+" "+dbtxdat+" "+dbxmail+" "+dbbilldat);
//displaySQLErrors (insertException);
}
} // end no ts
答案 0 :(得分:0)
在你的catch块中添加这行e.printStackTrace()。执行代码并检查excat错误。 还有什么是tbts?这个表名是?如果这是变量,你有表名,那么它在你的代码
中的任何地方定义