mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
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
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user