aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/example/basic.java
diff options
context:
space:
mode:
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..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