mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Wed Jan 31 08:46:00 GMT 2001 peter@retep.org.uk
- Some minor additions to Statement to make our own extensions more portable. - Statement.close() will now call ResultSet.close() rather than just dissasociating with it.
This commit is contained in:
42
src/interfaces/jdbc/org/postgresql/Statement.java
Normal file
42
src/interfaces/jdbc/org/postgresql/Statement.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package org.postgresql;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* This class defines methods implemented by the two subclasses
|
||||
* org.postgresql.jdbc1.Statement and org.postgresql.jdbc2.Statement that are
|
||||
* unique to PostgreSQL's JDBC driver.
|
||||
*
|
||||
* <p>They are defined so that client code can cast to org.postgresql.Statement
|
||||
* without having to predetermine the jdbc driver type.
|
||||
*
|
||||
* <p>ie: Before this class existed, you had to use:
|
||||
*
|
||||
* <p>((org.postgresql.jdbc2.Statement)stat).getInsertedOID();
|
||||
*
|
||||
* <p>now you use:
|
||||
*
|
||||
* <p>((org.postgresql.Statement)stat).getInsertedOID();
|
||||
*
|
||||
* <p>As you can see, this is independent of JDBC1.2, JDBC2.0 or the upcoming
|
||||
* JDBC3.
|
||||
*/
|
||||
|
||||
public abstract class Statement {
|
||||
|
||||
public Statement() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status message from the current Result.<p>
|
||||
* This is used internally by the driver.
|
||||
*
|
||||
* @return status message from backend
|
||||
*/
|
||||
public abstract String getResultStatusString();
|
||||
|
||||
/**
|
||||
* @return the OID of the last row inserted
|
||||
*/
|
||||
public abstract int getInsertedOID() throws SQLException;
|
||||
}
|
@@ -90,7 +90,13 @@ public class Statement implements java.sql.Statement
|
||||
*/
|
||||
public void close() throws SQLException
|
||||
{
|
||||
result = null;
|
||||
// Force the ResultSet to close
|
||||
java.sql.ResultSet rs = getResultSet();
|
||||
if(rs!=null)
|
||||
rs.close();
|
||||
|
||||
// Disasociate it from us (For Garbage Collection)
|
||||
result = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,4 +333,18 @@ public class Statement implements java.sql.Statement
|
||||
return null;
|
||||
return ((org.postgresql.ResultSet)result).getStatusString();
|
||||
}
|
||||
|
||||
/**
|
||||
* New in 7.1: Returns the Last inserted oid. This should be used, rather
|
||||
* than the old method using getResultSet, which for executeUpdate returns
|
||||
* null.
|
||||
* @return OID of last insert
|
||||
*/
|
||||
public int getInsertedOID() throws SQLException
|
||||
{
|
||||
if(result!=null)
|
||||
return ((org.postgresql.ResultSet)result).getInsertedOID();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ import org.postgresql.util.*;
|
||||
* @see java.sql.Statement
|
||||
* @see ResultSet
|
||||
*/
|
||||
public class Statement implements java.sql.Statement
|
||||
public class Statement extends org.postgresql.Statement implements java.sql.Statement
|
||||
{
|
||||
Connection connection; // The connection who created us
|
||||
java.sql.ResultSet result = null; // The current results
|
||||
@@ -95,7 +95,13 @@ public class Statement implements java.sql.Statement
|
||||
*/
|
||||
public void close() throws SQLException
|
||||
{
|
||||
result = null;
|
||||
// Force the ResultSet to close
|
||||
java.sql.ResultSet rs = getResultSet();
|
||||
if(rs!=null)
|
||||
rs.close();
|
||||
|
||||
// Disasociate it from us (For Garbage Collection)
|
||||
result = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user