Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit234599e

Browse files
author
Peter Mount
committed
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.
1 parent8439a83 commit234599e

File tree

6 files changed

+80
-6
lines changed

6 files changed

+80
-6
lines changed

‎src/interfaces/jdbc/CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Wed Jan 31 08:46:00 GMT 2001 peter@retep.org.uk
2+
- Some minor additions to Statement to make our own extensions more
3+
portable.
4+
- Statement.close() will now call ResultSet.close() rather than just
5+
dissasociating with it.
6+
17
Tue Jan 30 22:24:00 GMT 2001 peter@retep.org.uk
28
- Fixed bug where Statement.setMaxRows() was a global setting. Now
39
limited to just itself.

‎src/interfaces/jdbc/example/basic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
*
9-
* $Id: basic.java,v 1.6 2001/01/3108:26:01 peter Exp $
9+
* $Id: basic.java,v 1.7 2001/01/3109:23:45 peter Exp $
1010
*
1111
* This example tests the basic components of the JDBC driver, and shows
1212
* how even the simplest of queries can be implemented.
@@ -86,7 +86,7 @@ public void doexample() throws SQLException
8686
// This shows how to get the oid of a just inserted row
8787
// updated for 7.1
8888
st.executeUpdate("insert into basic values (4,1)");
89-
intinsertedOID = ((org.postgresql.jdbc2.Statement)st).getInsertedOID();
89+
intinsertedOID = ((org.postgresql.Statement)st).getInsertedOID();
9090
System.out.println("Inserted row with oid "+insertedOID);
9191

9292
// Now change the value of b from 1 to 8

‎src/interfaces/jdbc/jdbc.jpx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<propertycategory="sys"name="CheckStable"value="1" />
1010
<propertycategory="sys"name="Company"value="" />
1111
<propertycategory="sys"name="Copyright"value="Copyright (c) 2001" />
12-
<propertycategory="sys"name="DefaultPackage"value="org.postgresql.largeobject" />
12+
<propertycategory="sys"name="DefaultPackage"value="org.postgresql" />
1313
<propertycategory="sys"name="Description"value="" />
1414
<propertycategory="sys"name="DocPath"value="doc" />
1515
<propertycategory="sys"name="ExcludeClassEnabled"value="0" />
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
packageorg.postgresql;
2+
3+
importjava.sql.SQLException;
4+
5+
/**
6+
* This class defines methods implemented by the two subclasses
7+
* org.postgresql.jdbc1.Statement and org.postgresql.jdbc2.Statement that are
8+
* unique to PostgreSQL's JDBC driver.
9+
*
10+
* <p>They are defined so that client code can cast to org.postgresql.Statement
11+
* without having to predetermine the jdbc driver type.
12+
*
13+
* <p>ie: Before this class existed, you had to use:
14+
*
15+
* <p>((org.postgresql.jdbc2.Statement)stat).getInsertedOID();
16+
*
17+
* <p>now you use:
18+
*
19+
* <p>((org.postgresql.Statement)stat).getInsertedOID();
20+
*
21+
* <p>As you can see, this is independent of JDBC1.2, JDBC2.0 or the upcoming
22+
* JDBC3.
23+
*/
24+
25+
publicabstractclassStatement {
26+
27+
publicStatement() {
28+
}
29+
30+
/**
31+
* Returns the status message from the current Result.<p>
32+
* This is used internally by the driver.
33+
*
34+
* @return status message from backend
35+
*/
36+
publicabstractStringgetResultStatusString();
37+
38+
/**
39+
* @return the OID of the last row inserted
40+
*/
41+
publicabstractintgetInsertedOID()throwsSQLException;
42+
}

‎src/interfaces/jdbc/org/postgresql/jdbc1/Statement.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ public int executeUpdate(String sql) throws SQLException
9090
*/
9191
publicvoidclose()throwsSQLException
9292
{
93-
result =null;
93+
// Force the ResultSet to close
94+
java.sql.ResultSetrs =getResultSet();
95+
if(rs!=null)
96+
rs.close();
97+
98+
// Disasociate it from us (For Garbage Collection)
99+
result =null;
94100
}
95101

96102
/**
@@ -327,4 +333,18 @@ public String getResultStatusString()
327333
returnnull;
328334
return ((org.postgresql.ResultSet)result).getStatusString();
329335
}
336+
337+
/**
338+
* New in 7.1: Returns the Last inserted oid. This should be used, rather
339+
* than the old method using getResultSet, which for executeUpdate returns
340+
* null.
341+
* @return OID of last insert
342+
*/
343+
publicintgetInsertedOID()throwsSQLException
344+
{
345+
if(result!=null)
346+
return ((org.postgresql.ResultSet)result).getInsertedOID();
347+
return0;
348+
}
349+
330350
}

‎src/interfaces/jdbc/org/postgresql/jdbc2/Statement.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @see java.sql.Statement
2323
* @see ResultSet
2424
*/
25-
publicclassStatementimplementsjava.sql.Statement
25+
publicclassStatementextendsorg.postgresql.Statementimplementsjava.sql.Statement
2626
{
2727
Connectionconnection;// The connection who created us
2828
java.sql.ResultSetresult =null;// The current results
@@ -95,7 +95,13 @@ public int executeUpdate(String sql) throws SQLException
9595
*/
9696
publicvoidclose()throwsSQLException
9797
{
98-
result =null;
98+
// Force the ResultSet to close
99+
java.sql.ResultSetrs =getResultSet();
100+
if(rs!=null)
101+
rs.close();
102+
103+
// Disasociate it from us (For Garbage Collection)
104+
result =null;
99105
}
100106

101107
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp