From 3f59cc08316f9aea92823a021c6232b298e00d03 Mon Sep 17 00:00:00 2001 From: Peter Mount Date: Mon, 17 May 1999 22:43:30 +0000 Subject: Minor bug fixes. Replaced DateStyle support with ISO. --- .../jdbc/postgresql/jdbc2/Statement.java | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/interfaces/jdbc/postgresql/jdbc2/Statement.java') 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