From cb0a1deb2d1ebfbe9b9b4a5fd5781f29c6d283bc Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 18 Jan 2007 00:31:36 +0000 Subject: [PATCH] * [ 1638139 ] WAN: Insert new record error --- dbPort/src/org/compiere/util/DB.java | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/dbPort/src/org/compiere/util/DB.java b/dbPort/src/org/compiere/util/DB.java index 5ac7c34a30..c9ab35cdfe 100644 --- a/dbPort/src/org/compiere/util/DB.java +++ b/dbPort/src/org/compiere/util/DB.java @@ -1022,30 +1022,24 @@ public final class DB /** * Execute Update and throw exception. - * @param SQL sql + * @param sql * @return number of rows updated or -1 if error * @param trxName transaction * @throws SQLException */ - public static int executeUpdateEx (String SQL, String trxName) throws SQLException + public static int executeUpdateEx (String sql, String trxName) throws SQLException { - if (SQL == null || SQL.length() == 0) - throw new IllegalArgumentException("Required parameter missing - " + SQL); + if (sql == null || sql.length() == 0) + throw new IllegalArgumentException("Required parameter missing - " + sql); // - String sql = getDatabase().convertStatement(SQL); int no = -1; + CPreparedStatement cs = new CPreparedStatement(ResultSet.TYPE_FORWARD_ONLY, + ResultSet.CONCUR_UPDATABLE, sql, trxName); // converted in call + SQLException ex = null; - Connection conn = null; - Statement stmt = null; try { - Trx trx = trxName == null ? null : Trx.get(trxName, true); - if (trx != null) - conn = trx.getConnection(); - else - conn = DB.getConnectionRW (); - stmt = conn.createStatement(); - no = stmt.executeUpdate(sql); + no = cs.executeUpdate(); } catch (SQLException e) { @@ -1057,7 +1051,7 @@ public final class DB // Always close cursor try { - stmt.close(); + cs.close(); } catch (SQLException e2) { @@ -1065,7 +1059,7 @@ public final class DB } } if (ex != null) - throw new SQLException(ex.getMessage(), ex.getSQLState(), ex.getErrorCode()); + throw ex; return no; } // execute Update