diff options
author | Peter Mount <peter@retep.org.uk> | 1999-05-17 22:43:30 +0000 |
---|---|---|
committer | Peter Mount <peter@retep.org.uk> | 1999-05-17 22:43:30 +0000 |
commit | 3f59cc08316f9aea92823a021c6232b298e00d03 (patch) | |
tree | 3c8a787e2346fce5e4d324dcb5f80c76a145beab /src/interfaces/jdbc/postgresql/jdbc2/Statement.java | |
parent | c2b75c83f341cf06f6594235b40281ec3956538e (diff) | |
download | postgresql-3f59cc08316f9aea92823a021c6232b298e00d03.tar.gz |
Minor bug fixes. Replaced DateStyle support with ISO.
Diffstat (limited to 'src/interfaces/jdbc/postgresql/jdbc2/Statement.java')
-rw-r--r-- | src/interfaces/jdbc/postgresql/jdbc2/Statement.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/interfaces/jdbc/postgresql/jdbc2/Statement.java b/src/interfaces/jdbc/postgresql/jdbc2/Statement.java index 427efe14df..4c9c8c9e01 100644 --- a/src/interfaces/jdbc/postgresql/jdbc2/Statement.java +++ b/src/interfaces/jdbc/postgresql/jdbc2/Statement.java @@ -6,6 +6,7 @@ package postgresql.jdbc2; // postgresql.jdbc1 package. import java.sql.*; +import java.util.Vector; /** * A Statement object is used for executing a static SQL statement and @@ -27,6 +28,7 @@ public class Statement implements java.sql.Statement SQLWarning warnings = null; // The warnings chain. int timeout = 0; // The timeout for a query (not used) boolean escapeProcessing = true;// escape processing flag + private Vector batch=null; /** * Constructor for a Statement. It simply sets the connection @@ -325,17 +327,35 @@ public class Statement implements java.sql.Statement public void addBatch(String sql) throws SQLException { - throw postgresql.Driver.notImplemented(); + if(batch==null) + batch=new Vector(); + batch.addElement(sql); } public void clearBatch() throws SQLException { - throw postgresql.Driver.notImplemented(); + if(batch!=null) + batch.removeAllElements(); } public int[] executeBatch() throws SQLException { - throw postgresql.Driver.notImplemented(); + if(batch==null || batch.isEmpty()) + throw new SQLException("The batch is empty."); + + int size=batch.size(); + int[] result=new int[size]; + int i=0; + this.execute("begin"); // PTM: check this when autoCommit is false + try { + for(i=0;i<size;i++) + result[i]=this.executeUpdate((String)batch.elementAt(i)); + this.execute("commit"); // PTM: check this + } catch(SQLException e) { + this.execute("abort"); // PTM: check this + throw new SQLException("The result "+i+" \""+batch.elementAt(i)+"\" aborted."); + } + return result; } public java.sql.Connection getConnection() throws SQLException |