当前位置: 技术问答>java相关
这段与事务有关的代码错在哪里?
来源: 互联网 发布时间:2015-08-24
本文导语: String strInsertReportID="insert into tbMain (DepartmentID)values("+DepartmentID+")"; String strReportID="select max(ReportID) from tbMain where UnitID= "+SDepartmentID; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:od...
String strInsertReportID="insert into tbMain (DepartmentID)values("+DepartmentID+")";
String strReportID="select max(ReportID) from tbMain where UnitID= "+SDepartmentID;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:test","aa","aa");
conn.setAutoCommit(false);
java.sql.Statement stmt=conn.createStatement();
stmt.execute(strInsertReportID);
ResultSet rsid=stmt.executeQuery(strReportID);
while(rsid.next())
{count++;
}
if (count>0)
{
rsid.close();
rsid=stmt.executeQuery(strReportID);
rsid.next();
int maxReportID=rsid.getInt(1);
Integer ImaxReportID=new Integer(maxReportID);
SmaxReportID=ImaxReportID.toString();
}
else
{
}
for(int i=1;i