diff options
author | Peter Mount <peter@retep.org.uk> | 2000-06-06 11:06:09 +0000 |
---|---|---|
committer | Peter Mount <peter@retep.org.uk> | 2000-06-06 11:06:09 +0000 |
commit | e3cc370d155c3cbf97f179a98d64c2ce1550e25f (patch) | |
tree | 76deb5ad984dfe90d78804541217dbf0db4f5878 /src/interfaces/jdbc/example/basic.java | |
parent | 0e38f0a1d11ce6c93f4c38f636dcd9e6afee4ce9 (diff) | |
download | postgresql-e3cc370d155c3cbf97f179a98d64c2ce1550e25f.tar.gz postgresql-e3cc370d155c3cbf97f179a98d64c2ce1550e25f.zip |
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/example/basic.java')
-rw-r--r-- | src/interfaces/jdbc/example/basic.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/interfaces/jdbc/example/basic.java b/src/interfaces/jdbc/example/basic.java index 326c49c0f17..41302200ec1 100644 --- a/src/interfaces/jdbc/example/basic.java +++ b/src/interfaces/jdbc/example/basic.java @@ -6,7 +6,7 @@ import java.text.*; /** * - * $Id: basic.java,v 1.4 2000/04/26 05:32:00 peter Exp $ + * $Id: basic.java,v 1.5 2000/06/06 11:05:57 peter Exp $ * * This example tests the basic components of the JDBC driver, and shows * how even the simplest of queries can be implemented. @@ -83,10 +83,19 @@ public class basic st.executeUpdate("insert into basic values (2,1)"); st.executeUpdate("insert into basic values (3,1)"); + // This shows how to get the oid of a just inserted row + st.executeUpdate("insert into basic values (4,1)"); + int insertedOID = ((org.postgresql.ResultSet)st.getResultSet()).getInsertedOID(); + System.out.println("Inserted row with oid "+insertedOID); + // Now change the value of b from 1 to 8 st.executeUpdate("update basic set b=8"); System.out.println("Updated "+st.getUpdateCount()+" rows"); + // Now delete 2 rows + st.executeUpdate("delete from basic where a<3"); + System.out.println("deleted "+st.getUpdateCount()+" rows"); + // For large inserts, a PreparedStatement is more efficient, because it // supports the idea of precompiling the SQL statement, and to store // directly, a Java object into any column. PostgreSQL doesnt support |