本帖最后由 liu871113 于 2016-1-31 18:51 编辑 我又来了,各位大神,帮我看看代码, package com.fr.data; import com.fr.data.DefinedSubmitJob; import com.fr.data.JobValue; import com.fr.script.Calculator; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class DemoSubmitJob1 extends DefinedSubmitJob { /** * 当模板自定义事件增加的属性 名称与下面变量有对应时,则会自动赋值于此对应变量 */ static final String JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; static final String DB_URL = "jdbc:sqlserver://localhost:1433;databaseName=EasyERP"; // Database credentials static final String USER = "sa"; static final String PASS = "Hammsen1"; private JobValue ItemID; // 物料ID private JobValue shelfID;//货架ID private JobValue InStore;//单元格中入库数量 public int quantityInStore;// 非单元格,则对应具体类型值 /** * 每一条记录执行一次此方法 * 同一提交事件在一个处理事务内,此对象是唯一的 */ public void doJob(Calculator calculator) throws Exception { Connection conn = null; Statement stmt = null; //STEP 2: Register JDBC driver Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //STEP 3: Open a connection // System.out.println("Connecting to database..."); conn = DriverManager.getConnection(DB_URL,USER,PASS); //STEP 4: Execute a query //System.out.println("Creating statement..."); stmt = conn.createStatement(); String sql; sql = "select quantityInStore from MM_Storage where ItemID ='" + ItemID.getValue() + "' AND shelfID ='" + shelfID.getValue() + "' "; ResultSet rs = stmt.executeQuery(sql); rs.next(); int Num = rs.getInt(1); if(Num==0){ stmt.executeUpdate("insert into MM_Storage(ItemID,shelfID,quantityInStore) values("+ItemID.getValue()+","+shelfID.getValue()+","+InStore.getValue()+")"); }else{ quantityInStore = Num+InStore.getValue(); stmt.executeUpdate("update MM_Storage set quantityInStore ="+quantityInStore+" "+ "where ItemID ="+ItemID.getValue()+"AND"+"shelfID = "+shelfID.getValue()); } rs.close(); stmt.close(); conn.close(); } } 下面是日志: 2016-01-31 17:49:24 正常:Rollback Successfully 2016-01-31 17:49:24 警告:数据提交出错 null at com.fr.report.write.ReportWriteAttr.submit(Unknown Source) at com.fr.report.core.ReportUtils.submit(Unknown Source) at com.fr.report.core.ReportUtils.submit(Unknown Source) at com.fr.web.core.A.AB.actionCMD(Unknown Source) at com.fr.web.core.WebActionsDispatcher.dealForActionCMD(Unknown Source) at com.fr.web.core.WebActionsDispatcher.dealForActionDefaultCmd(Unknown Source) at com.fr.web.core.WebActionsDispatcher.dealForActionCMD(Unknown Source) at com.fr.web.core.A.cC.process(Unknown Source) at com.fr.web.core.ReportDispatcher.dealWithOp(Unknown Source) at com.fr.web.core.ReportDispatcher.dealWeblet(Unknown Source) at com.fr.web.core.ReportDispatcher.dealWithRequest(Unknown Source) at com.fr.web.BaseServlet.doGet(Unknown Source) at com.fr.web.BaseServlet.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:616) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1530) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633) at org.mortbay.http.HttpContext.handle(HttpContext.java:1482) at org.mortbay.http.HttpServer.service(HttpServer.java:909) at org.mortbay.http.HttpConnection.service(HttpConnection.java:820) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) 以上是日志信息,求帮助啊啊 |