summaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/example/basic.java
diff options
context:
space:
mode:
authorBruce Momjian2000-06-15 04:12:41 +0000
committerBruce Momjian2000-06-15 04:12:41 +0000
commitc545ec54f8139e7f02e39a138fc5f21ebdc33b7b (patch)
tree9c2a97b57fe003b2556246be2005f0a0a2c1c163 /src/interfaces/jdbc/example/basic.java
parent3a82b67b22ab61812b06e4051b003e3854d55b99 (diff)
Backpatch jdbc fixes into 7.0.X.
Diffstat (limited to 'src/interfaces/jdbc/example/basic.java')
-rw-r--r--src/interfaces/jdbc/example/basic.java11
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..5e23e26512b 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.4.2.1 2000/06/15 04:12:24 momjian 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