Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1e31873

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 restructures the code so that the duplication is removed so that the jdbc3 support can be added without adding yet another copy of everything. Also many classes were renamed to avoid confusion with multiple different objects having the same name. The timestamp tests were also updated to add support for 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 parent e9c013f commit 1e31873

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
clean distclean maintainer-clean:
3939
$(ANT) -buildfile $(srcdir)/build.xml clean
4040

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

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
<target name="check_versions">
3535
<condition property="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
<condition property="jdbc3">
4645
<equals arg1="${ant.java.version}" arg2="1.4"/>
4746
</condition>
48-
<condition property="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-
<available classname="javax.sql.DataSource"/>
56-
</and>
57-
</condition>
47+
<available property="datasource" classname="javax.sql.DataSource"/>
5848
<available property="junit" classname="junit.framework.Test" />
5949
</target>
6050

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

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

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

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

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

@@ -121,10 +112,10 @@
121112
<equals arg1="${jdbc1}" arg2="true"/>
122113
</condition>
123114
<condition property="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+
<condition property="edition" value="JDBC3">
118+
<equals arg1="${jdbc3}" arg2="true"/>
128119
</condition>
129120
<condition property="edition" value="JDBC2 Enterprise">
130121
<and>
@@ -134,8 +125,8 @@
134125
</condition>
135126

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

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

180171

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

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

237228
<java fork="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-
LargeObjectManager lom = ((org.postgresql.Connection)db).getLargeObjectAPI();
302+
LargeObjectManager lom = ((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-
long insertedOID = ((org.postgresql.Statement)st).getLastOID();
91+
long insertedOID = ((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
int oid = 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
private int mod; // type modifier of this field
1818
private String name; // Name of this field
1919

20-
private Connection conn; // Connection Instantation
20+
private org.postgresql.PGConnection conn; // 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-
public Field(Connection conn, String name, int oid, int length, int mod)
31+
public Field(org.postgresql.PGConnection conn, String name, int oid, int length, int mod)
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-
public Field(Connection conn, String name, int oid, int length)
48+
public Field(org.postgresql.PGConnection conn, String name, int oid, int length)
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+
package org.postgresql;
2+
3+
import java.sql.*;
4+
import java.util.Properties;
5+
import java.util.Vector;
6+
import org.postgresql.core.Encoding;
7+
import org.postgresql.fastpath.Fastpath;
8+
import org.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+
public interface PGConnection
16+
{
17+
/*
18+
* Get the character encoding to use for this connection.
19+
*/
20+
public Encoding getEncoding() throws SQLException;
21+
22+
/*
23+
* This method returns the java.sql.Types type for a postgres datatype name
24+
*/
25+
public int getSQLType(String pgTypeName) throws SQLException;
26+
27+
/*
28+
* This returns the java.sql.Types type for a postgres datatype OID
29+
*/
30+
public int getSQLType(int oid) throws SQLException;
31+
32+
/*
33+
* This returns the postgres datatype name from the
34+
* postgres datatype OID
35+
*/
36+
public String getPGType(int oid) throws SQLException;
37+
38+
/*
39+
* This returns the postgres datatype OID from the
40+
* postgres datatype name
41+
*/
42+
public int getPGType(String typeName) throws SQLException;
43+
44+
/*
45+
* This returns the LargeObject API for the current connection.
46+
*/
47+
public LargeObjectManager getLargeObjectAPI() throws SQLException;
48+
49+
/*
50+
* This returns the Fastpath API for the current connection.
51+
*/
52+
public Fastpath getFastpathAPI() throws SQLException;
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+
public Object getObject(String type, String value) throws SQLException;
70+
71+
}
72+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.postgresql;
2+
3+
4+
import java.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+
public interface PGStatement
12+
{
13+
14+
/*
15+
* Returns the Last inserted/updated oid.
16+
* @return OID of last insert
17+
* @since 7.3
18+
*/
19+
public long getLastOID() throws SQLException;
20+
21+
}

0 commit comments

Comments
 (0)