mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-01 00:51:15 +02: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:
parent
8439a83d84
commit
234599e943
@ -1,3 +1,9 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
Tue Jan 30 22:24:00 GMT 2001 peter@retep.org.uk
|
Tue Jan 30 22:24:00 GMT 2001 peter@retep.org.uk
|
||||||
- Fixed bug where Statement.setMaxRows() was a global setting. Now
|
- Fixed bug where Statement.setMaxRows() was a global setting. Now
|
||||||
limited to just itself.
|
limited to just itself.
|
||||||
|
@ -6,7 +6,7 @@ import java.text.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* $Id: basic.java,v 1.6 2001/01/31 08:26:01 peter Exp $
|
* $Id: basic.java,v 1.7 2001/01/31 09:23:45 peter Exp $
|
||||||
*
|
*
|
||||||
* This example tests the basic components of the JDBC driver, and shows
|
* This example tests the basic components of the JDBC driver, and shows
|
||||||
* how even the simplest of queries can be implemented.
|
* how even the simplest of queries can be implemented.
|
||||||
@ -86,7 +86,7 @@ public class basic
|
|||||||
// This shows how to get the oid of a just inserted row
|
// This shows how to get the oid of a just inserted row
|
||||||
// updated for 7.1
|
// updated for 7.1
|
||||||
st.executeUpdate("insert into basic values (4,1)");
|
st.executeUpdate("insert into basic values (4,1)");
|
||||||
int insertedOID = ((org.postgresql.jdbc2.Statement)st).getInsertedOID();
|
int insertedOID = ((org.postgresql.Statement)st).getInsertedOID();
|
||||||
System.out.println("Inserted row with oid "+insertedOID);
|
System.out.println("Inserted row with oid "+insertedOID);
|
||||||
|
|
||||||
// Now change the value of b from 1 to 8
|
// Now change the value of b from 1 to 8
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<property category="sys" name="CheckStable" value="1" />
|
<property category="sys" name="CheckStable" value="1" />
|
||||||
<property category="sys" name="Company" value="" />
|
<property category="sys" name="Company" value="" />
|
||||||
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
|
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
|
||||||
<property category="sys" name="DefaultPackage" value="org.postgresql.largeobject" />
|
<property category="sys" name="DefaultPackage" value="org.postgresql" />
|
||||||
<property category="sys" name="Description" value="" />
|
<property category="sys" name="Description" value="" />
|
||||||
<property category="sys" name="DocPath" value="doc" />
|
<property category="sys" name="DocPath" value="doc" />
|
||||||
<property category="sys" name="ExcludeClassEnabled" value="0" />
|
<property category="sys" name="ExcludeClassEnabled" value="0" />
|
||||||
|
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
|
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 null;
|
||||||
return ((org.postgresql.ResultSet)result).getStatusString();
|
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 java.sql.Statement
|
||||||
* @see ResultSet
|
* @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
|
Connection connection; // The connection who created us
|
||||||
java.sql.ResultSet result = null; // The current results
|
java.sql.ResultSet result = null; // The current results
|
||||||
@ -95,7 +95,13 @@ public class Statement implements java.sql.Statement
|
|||||||
*/
|
*/
|
||||||
public void close() throws SQLException
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user