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

Commit1e31873

Browse files
author
Barry Lind
committed
Initial restructuring to add jdbc3 support. There was a significant amount
of duplicated code between the jdbc1 and jdbc2. This checkin restructuresthe code so that the duplication is removed so that the jdbc3 supportcan be added without adding yet another copy of everything. Also manyclasses were renamed to avoid confusion with multiple different objectshaving the same name. The timestamp tests were also updated to add supportfor testing timestamp without time zone in addition to timestamp with time zone Modified Files: jdbc/Makefile jdbc/build.xml jdbc/example/ImageViewer.java jdbc/example/basic.java jdbc/example/blobtest.java jdbc/example/threadsafe.java jdbc/org/postgresql/Driver.java.in jdbc/org/postgresql/Field.java jdbc/org/postgresql/core/QueryExecutor.java jdbc/org/postgresql/fastpath/Fastpath.java jdbc/org/postgresql/jdbc1/CallableStatement.java jdbc/org/postgresql/jdbc1/DatabaseMetaData.java jdbc/org/postgresql/jdbc1/PreparedStatement.java jdbc/org/postgresql/jdbc2/Array.java jdbc/org/postgresql/jdbc2/CallableStatement.java jdbc/org/postgresql/jdbc2/DatabaseMetaData.java jdbc/org/postgresql/jdbc2/PreparedStatement.java jdbc/org/postgresql/jdbc2/UpdateableResultSet.java jdbc/org/postgresql/largeobject/LargeObjectManager.java jdbc/org/postgresql/largeobject/PGblob.java jdbc/org/postgresql/largeobject/PGclob.java jdbc/org/postgresql/test/jdbc2/BlobTest.java jdbc/org/postgresql/test/jdbc2/ConnectionTest.java jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java jdbc/org/postgresql/test/jdbc2/TimestampTest.java jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java jdbc/org/postgresql/util/Serialize.java Added Files: jdbc/org/postgresql/PGConnection.java jdbc/org/postgresql/PGStatement.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/jdbc1/Jdbc1Connection.java jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java jdbc/org/postgresql/jdbc1/Jdbc1Statement.java jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java jdbc/org/postgresql/jdbc2/Jdbc2Connection.java jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java jdbc/org/postgresql/jdbc2/Jdbc2Statement.java Removed Files: jdbc/org/postgresql/Connection.java jdbc/org/postgresql/ResultSet.java jdbc/org/postgresql/Statement.java jdbc/org/postgresql/jdbc1/Connection.java jdbc/org/postgresql/jdbc1/ResultSet.java jdbc/org/postgresql/jdbc1/Statement.java jdbc/org/postgresql/jdbc2/Connection.java jdbc/org/postgresql/jdbc2/ResultSet.java jdbc/org/postgresql/jdbc2/Statement.java
1 parente9c013f commit1e31873

File tree

48 files changed

+3033
-4522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3033
-4522
lines changed

‎src/interfaces/jdbc/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 2001, PostgreSQL Global Development Group
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.34 2002/03/05 17:55:23 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.35 2002/07/23 03:59:54 barry Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -38,5 +38,5 @@ uninstall:
3838
cleandistcleanmaintainer-clean:
3939
$(ANT) -buildfile$(srcdir)/build.xml clean
4040

41-
check:
41+
check: all
4242
$(ANT) -buildfile$(srcdir)/build.xmltest

‎src/interfaces/jdbc/build.xml‎

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
This file now requires Ant 1.4.1. 2002-04-18
88
9-
$Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.24 2002/06/27 04:38:01 barry Exp $
9+
$Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.25 2002/07/23 03:59:54 barry Exp $
1010
1111
-->
1212

@@ -29,7 +29,7 @@
2929
in the CLASSPATH (ie JDK1.2 or later), and then enterprise if the
3030
javax.sql.DataSource class is present.
3131
32-
Important: This must have the following order: jdbc1, jdbc2,enterprise
32+
Important: This must have the following order: jdbc1, jdbc2,jdbc3
3333
-->
3434
<targetname="check_versions">
3535
<conditionproperty="jdbc1">
@@ -39,22 +39,12 @@
3939
<or>
4040
<equals arg1="${ant.java.version}" arg2="1.2"/>
4141
<equals arg1="${ant.java.version}" arg2="1.3"/>
42-
<equals arg1="${ant.java.version}" arg2="1.4"/>
4342
</or>
4443
</condition>
4544
<conditionproperty="jdbc3">
4645
<equals arg1="${ant.java.version}" arg2="1.4"/>
4746
</condition>
48-
<conditionproperty="datasource">
49-
<and>
50-
<or>
51-
<equals arg1="${ant.java.version}" arg2="1.2"/>
52-
<equals arg1="${ant.java.version}" arg2="1.3"/>
53-
<equals arg1="${ant.java.version}" arg2="1.4"/>
54-
</or>
55-
<availableclassname="javax.sql.DataSource"/>
56-
</and>
57-
</condition>
47+
<availableproperty="datasource"classname="javax.sql.DataSource"/>
5848
<availableproperty="junit"classname="junit.framework.Test" />
5949
</target>
6050

@@ -97,16 +87,17 @@
9787

9888
<excludename="${package}/jdbc1/**"unless="jdbc1"/>
9989
<excludename="${package}/jdbc2/**"unless="jdbc2"/>
90+
<excludename="${package}/jdbc3/**"unless="jdbc3"/>
10091

101-
<excludename="${package}/largeobject/PGblob.java"unless="jdbc2" />
102-
<excludename="${package}/largeobject/PGclob.java"unless="jdbc2" />
92+
<excludename="${package}/largeobject/PGblob.java"if="jdbc1" />
93+
<excludename="${package}/largeobject/PGclob.java"if="jdbc1" />
10394

10495
<excludename="${package}/PostgresqlDataSource.java"unless="datasource" />
10596
<excludename="${package}/xa/**"unless="datasource" />
10697

10798
<excludename="${package}/test/**"unless="junit" />
108-
<excludename="${package}/test/jdbc2/**"unless="jdbc2" />
109-
<excludename="${package}/test/JDBC2Tests.java"unless="jdbc2" />
99+
<excludename="${package}/test/jdbc2/**"if="jdbc1" />
100+
<excludename="${package}/test/JDBC2Tests.java"if="jdbc1" />
110101
</javac>
111102
</target>
112103

@@ -121,10 +112,10 @@
121112
<equals arg1="${jdbc1}" arg2="true"/>
122113
</condition>
123114
<conditionproperty="edition"value="JDBC2">
124-
<or>
125115
<equals arg1="${jdbc2}" arg2="true"/>
126-
<equals arg1="${jdbc3}" arg2="true"/><!-- fake it for now-->
127-
</or>
116+
</condition>
117+
<conditionproperty="edition"value="JDBC3">
118+
<equals arg1="${jdbc3}" arg2="true"/>
128119
</condition>
129120
<conditionproperty="edition"value="JDBC2 Enterprise">
130121
<and>
@@ -134,8 +125,8 @@
134125
</condition>
135126

136127
<!-- determine the connection class-->
137-
<propertyname="connectclass"value="org.postgresql.jdbc1.Connection" />
138-
<availableproperty="connectclass"value="org.postgresql.jdbc2.Connection"classname="java.lang.ThreadLocal" />
128+
<propertyname="connectclass"value="org.postgresql.jdbc1.Jdbc1Connection" />
129+
<availableproperty="connectclass"value="org.postgresql.jdbc2.Jdbc2Connection"classname="java.lang.ThreadLocal" />
139130

140131
<!-- Some defaults-->
141132
<filtertoken="MAJORVERSION"value="${major}" />
@@ -173,13 +164,13 @@
173164
<javacsrcdir="${srcdir}"destdir="${builddir}"debug="${debug}">
174165
<includename="example/**" />
175166
<excludename="example/corba/**"/>
176-
<excludename="example/blobtest.java"unless="jdk1.2+"/>
167+
<excludename="example/blobtest.java"if="jdbc1"/>
177168
</javac>
178169
</target>
179170

180171

181172
<!-- Builds the corba example-->
182-
<targetname="corba"if="jdk1.2+">
173+
<targetname="corba"if="jdbc2">
183174
<execdir="${srcdir}/example/corba"executable="idl2java">
184175
<argvalue="stock.idl" />
185176
</exec>
@@ -230,8 +221,8 @@
230221

231222
<targetname="test"depends="jar"if="junit">
232223
<javacsrcdir="${srcdir}"destdir="${builddir}"debug="${debug}">
233-
<includename="${package}/test/jdbc2/**"if="jdk1.2+" />
234-
<includename="${package}/test/java2ee/**"if="jdk1.2e+" />
224+
<includename="${package}/test/jdbc2/**"if="jdbc2" />
225+
<includename="${package}/test/jdbc2/**"if="jdbc3" />
235226
</javac>
236227

237228
<javafork="yes"classname="junit.${junit.ui}.TestRunner"taskname="junit"failonerror="true">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void actionPerformed(ActionEvent e)
205205
stat =db.createStatement();
206206

207207
// Also, get the LargeObjectManager for this connection
208-
lom = ((org.postgresql.Connection)db).getLargeObjectAPI();
208+
lom = ((org.postgresql.PGConnection)db).getLargeObjectAPI();
209209

210210
// Now refresh the image selection list
211211
refreshList();
@@ -299,7 +299,7 @@ public void run()
299299
try
300300
{
301301
// fetch the large object manager
302-
LargeObjectManagerlom = ((org.postgresql.Connection)db).getLargeObjectAPI();
302+
LargeObjectManagerlom = ((org.postgresql.PGConnection)db).getLargeObjectAPI();
303303

304304
db.setAutoCommit(false);
305305

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

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

77
/*
88
*
9-
* $Id: basic.java,v 1.11 2001/11/25 23:26:56 barry Exp $
9+
* $Id: basic.java,v 1.12 2002/07/23 03:59:54 barry 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.
@@ -87,9 +87,8 @@ public void doexample() throws SQLException
8787
st.executeUpdate("insert into basic values (3,1)");
8888

8989
// This shows how to get the oid of a just inserted row
90-
// updated for 7.1
9190
st.executeUpdate("insert into basic values (4,1)");
92-
longinsertedOID = ((org.postgresql.Statement)st).getLastOID();
91+
longinsertedOID = ((org.postgresql.PGStatement)st).getLastOID();
9392
System.out.println("Inserted row with oid " +insertedOID);
9493

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void ownapi() throws FileNotFoundException, IOException, SQLException
7676
// objects, however the unique methods available to postgresql makes
7777
// things a little easier.
7878
System.out.println("Gaining access to large object api");
79-
lobj = ((org.postgresql.Connection)db).getLargeObjectAPI();
79+
lobj = ((org.postgresql.PGConnection)db).getLargeObjectAPI();
8080

8181
intoid =ownapi_test1();
8282
ownapi_test2(oid);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public thread3(Connection c) throws SQLException
301301
//st = c.createStatement();
302302

303303
// create a blob
304-
lom = ((org.postgresql.Connection)c).getLargeObjectAPI();
304+
lom = ((org.postgresql.PGConnection)c).getLargeObjectAPI();
305305
oid =lom.create();
306306
System.out.println("Thread 3 has created a blob of oid " +oid);
307307
}

‎src/interfaces/jdbc/org/postgresql/Driver.java.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public class Driver implements java.sql.Driver
116116
{
117117
if (Driver.logDebug) Driver.debug("connect " + url);
118118

119-
org.postgresql.Connection con = (org.postgresql.Connection)(Class.forName("@JDBCCONNECTCLASS@").newInstance());
119+
@JDBCCONNECTCLASS@ con = (@JDBCCONNECTCLASS@)(Class.forName("@JDBCCONNECTCLASS@").newInstance());
120120
con.openConnection (host(), port(), props, database(), url, this);
121121
return (java.sql.Connection)con;
122122
}

‎src/interfaces/jdbc/org/postgresql/Field.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Field
1717
privateintmod;// type modifier of this field
1818
privateStringname;// Name of this field
1919

20-
privateConnectionconn;// Connection Instantation
20+
privateorg.postgresql.PGConnectionconn;// Connection Instantation
2121

2222

2323
/*
@@ -28,7 +28,7 @@ public class Field
2828
* @param oid the OID of the field
2929
* @param len the length of the field
3030
*/
31-
publicField(Connectionconn,Stringname,intoid,intlength,intmod)
31+
publicField(org.postgresql.PGConnectionconn,Stringname,intoid,intlength,intmod)
3232
{
3333
this.conn =conn;
3434
this.name =name;
@@ -45,7 +45,7 @@ public Field(Connection conn, String name, int oid, int length, int mod)
4545
* @param oid the OID of the field
4646
* @param len the length of the field
4747
*/
48-
publicField(Connectionconn,Stringname,intoid,intlength)
48+
publicField(org.postgresql.PGConnectionconn,Stringname,intoid,intlength)
4949
{
5050
this(conn,name,oid,length,0);
5151
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
packageorg.postgresql;
2+
3+
importjava.sql.*;
4+
importjava.util.Properties;
5+
importjava.util.Vector;
6+
importorg.postgresql.core.Encoding;
7+
importorg.postgresql.fastpath.Fastpath;
8+
importorg.postgresql.largeobject.LargeObjectManager;
9+
10+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.1 2002/07/23 03:59:55 barry Exp $
11+
* This interface defines PostgreSQL extentions to the java.sql.Connection interface.
12+
* Any java.sql.Connection object returned by the driver will also implement this
13+
* interface
14+
*/
15+
publicinterfacePGConnection
16+
{
17+
/*
18+
* Get the character encoding to use for this connection.
19+
*/
20+
publicEncodinggetEncoding()throwsSQLException;
21+
22+
/*
23+
* This method returns the java.sql.Types type for a postgres datatype name
24+
*/
25+
publicintgetSQLType(StringpgTypeName)throwsSQLException;
26+
27+
/*
28+
* This returns the java.sql.Types type for a postgres datatype OID
29+
*/
30+
publicintgetSQLType(intoid)throwsSQLException;
31+
32+
/*
33+
* This returns the postgres datatype name from the
34+
* postgres datatype OID
35+
*/
36+
publicStringgetPGType(intoid)throwsSQLException;
37+
38+
/*
39+
* This returns the postgres datatype OID from the
40+
* postgres datatype name
41+
*/
42+
publicintgetPGType(StringtypeName)throwsSQLException;
43+
44+
/*
45+
* This returns the LargeObject API for the current connection.
46+
*/
47+
publicLargeObjectManagergetLargeObjectAPI()throwsSQLException;
48+
49+
/*
50+
* This returns the Fastpath API for the current connection.
51+
*/
52+
publicFastpathgetFastpathAPI()throwsSQLException;
53+
54+
/*
55+
* This method is used internally to return an object based around
56+
* org.postgresql's more unique data types.
57+
*
58+
* <p>It uses an internal Hashtable to get the handling class. If the
59+
* type is not supported, then an instance of org.postgresql.util.PGobject
60+
* is returned.
61+
*
62+
* You can use the getValue() or setValue() methods to handle the returned
63+
* object. Custom objects can have their own methods.
64+
*
65+
* @return PGobject for this type, and set to value
66+
* @exception SQLException if value is not correct for this type
67+
* @see org.postgresql.util.Serialize
68+
*/
69+
publicObjectgetObject(Stringtype,Stringvalue)throwsSQLException;
70+
71+
}
72+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
packageorg.postgresql;
2+
3+
4+
importjava.sql.*;
5+
6+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.3 2002/07/23 03:59:55 barry Exp $
7+
* This interface defines PostgreSQL extentions to the java.sql.Statement interface.
8+
* Any java.sql.Statement object returned by the driver will also implement this
9+
* interface
10+
*/
11+
publicinterfacePGStatement
12+
{
13+
14+
/*
15+
* Returns the Last inserted/updated oid.
16+
* @return OID of last insert
17+
* @since 7.3
18+
*/
19+
publiclonggetLastOID()throwsSQLException;
20+
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp