summaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/org/postgresql/Connection.java
diff options
context:
space:
mode:
authorPeter Mount <peter@retep.org.uk>2000-06-06 11:06:09 +0000
committerPeter Mount <peter@retep.org.uk>2000-06-06 11:06:09 +0000
commite3cc370d155c3cbf97f179a98d64c2ce1550e25f (patch)
tree76deb5ad984dfe90d78804541217dbf0db4f5878 /src/interfaces/jdbc/org/postgresql/Connection.java
parent0e38f0a1d11ce6c93f4c38f636dcd9e6afee4ce9 (diff)
downloadpostgresql-e3cc370d155c3cbf97f179a98d64c2ce1550e25f.tar.gz
Added org/postgresql/DriverClass.java to the list of files removed by make clean (it's dynamically built)
Fixed Statement, so that the update count is valid when an SQL DELETE operation is done. While fixing the update count, made it easier to get the OID of the last insert as well. Example is in example/basic.java
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/Connection.java')
-rw-r--r--src/interfaces/jdbc/org/postgresql/Connection.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/Connection.java b/src/interfaces/jdbc/org/postgresql/Connection.java
index e205206d45..539faecd3e 100644
--- a/src/interfaces/jdbc/org/postgresql/Connection.java
+++ b/src/interfaces/jdbc/org/postgresql/Connection.java
@@ -10,7 +10,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.3 2000/06/06 07:45:07 peter Exp $
+ * $Id: Connection.java,v 1.4 2000/06/06 11:05:59 peter Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -317,7 +317,8 @@ public abstract class Connection
int fqp = 0;
boolean hfr = false;
String recv_status = null, msg;
- int update_count = 1;
+ int update_count = 1;
+ int insert_oid = 0;
SQLException final_error = null;
// Commented out as the backend can now handle queries
@@ -359,12 +360,19 @@ public abstract class Connection
recv_status = pg_stream.ReceiveString(8192);
// Now handle the update count correctly.
- if(recv_status.startsWith("INSERT") || recv_status.startsWith("UPDATE")) {
+ if(recv_status.startsWith("INSERT") || recv_status.startsWith("UPDATE") || recv_status.startsWith("DELETE")) {
try {
update_count = Integer.parseInt(recv_status.substring(1+recv_status.lastIndexOf(' ')));
} catch(NumberFormatException nfe) {
throw new PSQLException("postgresql.con.fathom",recv_status);
}
+ if(recv_status.startsWith("INSERT")) {
+ try {
+ insert_oid = Integer.parseInt(recv_status.substring(1+recv_status.indexOf(' '),recv_status.lastIndexOf(' ')));
+ } catch(NumberFormatException nfe) {
+ throw new PSQLException("postgresql.con.fathom",recv_status);
+ }
+ }
}
if (fields != null)
hfr = true;
@@ -425,7 +433,7 @@ public abstract class Connection
if (final_error != null)
throw final_error;
- return getResultSet(this, fields, tuples, recv_status, update_count);
+ return getResultSet(this, fields, tuples, recv_status, update_count, insert_oid);
}
}
@@ -727,7 +735,7 @@ public abstract class Connection
* This returns a resultset. It must be overridden, so that the correct
* version (from jdbc1 or jdbc2) are returned.
*/
- protected abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn, Field[] fields, Vector tuples, String status, int updateCount) throws SQLException;
+ protected abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn, Field[] fields, Vector tuples, String status, int updateCount,int insertOID) throws SQLException;
public abstract void close() throws SQLException;