From ded46bd522979e16f0e8035603333b76da51e51b Mon Sep 17 00:00:00 2001 From: Peter Mount Date: Sun, 11 Apr 1999 18:03:00 +0000 Subject: Implement UpdateCount --- src/interfaces/jdbc/postgresql/Connection.java | 16 +++++++++++++--- src/interfaces/jdbc/postgresql/Statement.java | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/interfaces/jdbc/postgresql') diff --git a/src/interfaces/jdbc/postgresql/Connection.java b/src/interfaces/jdbc/postgresql/Connection.java index df354776f7f..4ec6fdb177c 100644 --- a/src/interfaces/jdbc/postgresql/Connection.java +++ b/src/interfaces/jdbc/postgresql/Connection.java @@ -10,7 +10,7 @@ import postgresql.largeobject.*; import postgresql.util.*; /** - * $Id: Connection.java,v 1.14 1999/01/17 04:51:50 momjian Exp $ + * $Id: Connection.java,v 1.15 1999/04/11 18:03:00 peter Exp $ * * This abstract class is used by postgresql.Driver to open either the JDBC1 or * JDBC2 versions of the Connection class. @@ -321,6 +321,7 @@ public abstract class Connection int fqp = 0; boolean hfr = false; String recv_status = null, msg; + int update_count = 1; SQLException final_error = null; if (sql.length() > 8192) @@ -358,6 +359,15 @@ public abstract class Connection break; case 'C': // Command Status recv_status = pg_stream.ReceiveString(8192); + + // Now handle the update count correctly. + if(recv_status.startsWith("INSERT") || recv_status.startsWith("UPDATE")) { + try { + update_count = Integer.parseInt(recv_status.substring(1+recv_status.lastIndexOf(' '))); + } catch(NumberFormatException nfe) { + throw new SQLException("Unable to fathom update count \""+recv_status+"\""); + } + } if (fields != null) hfr = true; else @@ -414,8 +424,8 @@ public abstract class Connection } if (final_error != null) throw final_error; - return getResultSet(this, fields, tuples, recv_status, 1); - //return new ResultSet(this, fields, tuples, recv_status, 1); + + return getResultSet(this, fields, tuples, recv_status, update_count); } } diff --git a/src/interfaces/jdbc/postgresql/Statement.java b/src/interfaces/jdbc/postgresql/Statement.java index 8a3332da011..3b6c20c9a4f 100644 --- a/src/interfaces/jdbc/postgresql/Statement.java +++ b/src/interfaces/jdbc/postgresql/Statement.java @@ -35,7 +35,7 @@ public class Statement implements java.sql.Statement } /** - * Execute a SQL statement that retruns a single ResultSet + * Execute a SQL statement that returns a single ResultSet * * @param sql typically a static SQL SELECT statement * @return a ResulSet that contains the data produced by the query -- cgit v1.2.3