Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40c4416

Browse files
author
Barry Lind
committed
Fouth (and final) phase of restructuring to add jdbc3 support.
Modified Files: jdbc/org/postgresql/Driver.java.in jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/jdbc1/Jdbc1Connection.java jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java jdbc/org/postgresql/jdbc2/Jdbc2Connection.java jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java Added Files: jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java jdbc/org/postgresql/jdbc1/Jdbc1DatabaseMetaData.java jdbc/org/postgresql/jdbc1/Jdbc1ResultSetMetaData.java jdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java jdbc/org/postgresql/jdbc2/Jdbc2DatabaseMetaData.java jdbc/org/postgresql/jdbc2/Jdbc2ResultSetMetaData.java Removed Files: jdbc/org/postgresql/jdbc1/DatabaseMetaData.java jdbc/org/postgresql/jdbc1/ResultSetMetaData.java jdbc/org/postgresql/jdbc2/DatabaseMetaData.java jdbc/org/postgresql/jdbc2/ResultSetMetaData.java
1 parent 68c6eff commit 40c4416

14 files changed

+114
-154
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,6 @@ public class Driver implements java.sql.Driver
442442
}
443443

444444
//The build number should be incremented for every new build
445-
private static int m_buildNumber = 102;
445+
private static int m_buildNumber = 103;
446446

447447
}

src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.postgresql.util.*;
1414

1515

16-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.2 2002/07/25 22:45:27 barry Exp $
16+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.3 2002/07/26 05:29:34 barry Exp $
1717
* This class defines methods of the jdbc1 specification. This class is
1818
* extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
1919
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
@@ -78,6 +78,10 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
7878
*/
7979
private int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED;
8080

81+
82+
public abstract java.sql.Statement createStatement() throws SQLException;
83+
84+
8185
/*
8286
* This method actually opens the connection. It is called by Driver.
8387
*
@@ -361,6 +365,8 @@ public org.postgresql.Driver getDriver()
361365

362366
public abstract java.sql.ResultSet getResultSet(Statement statement, org.postgresql.Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
363367

368+
public abstract java.sql.ResultSet getResultSet(Statement statement, org.postgresql.Field[] fields, Vector tuples, String status, int updateCount) throws SQLException;
369+
364370
/*
365371
* This adds a warning to the warning chain.
366372
* @param msg message to add

src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java renamed to src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,23 @@
11
package org.postgresql.jdbc1;
22

3-
// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
4-
// If you make any modifications to this file, you must make sure that the
5-
// changes are also made (if relevent) to the related JDBC 2 class in the
6-
// org.postgresql.jdbc2 package.
73

84
import java.sql.*;
95
import java.util.*;
106
import org.postgresql.Field;
117
import org.postgresql.util.PSQLException;
128

13-
/*
14-
* This class provides information about the database as a whole.
15-
*
16-
* $Id: DatabaseMetaData.java,v 1.49 2002/07/25 22:45:28 barry Exp $
17-
*
18-
* <p>Many of the methods here return lists of information in ResultSets. You
19-
* can use the normal ResultSet methods such as getString and getInt to
20-
* retrieve the data from these ResultSets. If a given form of metadata is
21-
* not available, these methods should throw a SQLException.
22-
*
23-
* <p>Some of these methods take arguments that are String patterns. These
24-
* arguments all have names such as fooPattern. Within a pattern String,
25-
* "%" means match any substring of 0 or more characters, and "_" means
26-
* match any one character. Only metadata entries matching the search
27-
* pattern are returned. if a search pattern argument is set to a null
28-
* ref, it means that argument's criteria should be dropped from the
29-
* search.
30-
*
31-
* <p>A SQLException will be throws if a driver does not support a meta
32-
* data method. In the case of methods that return a ResultSet, either
33-
* a ResultSet (which may be empty) is returned or a SQLException is
34-
* thrown.
35-
*
36-
* @see java.sql.DatabaseMetaData
37-
*/
38-
public class DatabaseMetaData implements java.sql.DatabaseMetaData
9+
public abstract class AbstractJdbc1DatabaseMetaData
3910
{
40-
Jdbc1Connection connection; // The connection association
11+
protected AbstractJdbc1Connection connection; // The connection association
4112

4213
// These define various OID's. Hopefully they will stay constant.
43-
static final int iVarcharOid = 1043; // OID for varchar
44-
static final int iBoolOid = 16; // OID for bool
45-
static final int iInt2Oid = 21; // OID for int2
46-
static final int iInt4Oid = 23; // OID for int4
47-
static final int VARHDRSZ = 4; // length for int4
14+
protected static final int iVarcharOid = 1043; // OID for varchar
15+
protected static final int iBoolOid = 16; // OID for bool
16+
protected static final int iInt2Oid = 21; // OID for int2
17+
protected static final int iInt4Oid = 23; // OID for int4
18+
protected static final int VARHDRSZ = 4; // length for int4
4819

49-
public DatabaseMetaData(Jdbc1Connection conn)
20+
public AbstractJdbc1DatabaseMetaData(AbstractJdbc1Connection conn)
5021
{
5122
this.connection = conn;
5223
}
@@ -2340,13 +2311,13 @@ else if (proname.endsWith("_del"))
23402311
if (col > -1)
23412312
{
23422313
String rule = proname.substring(8, proname.length() - 4);
2343-
int action = importedKeyNoAction;
2314+
int action = java.sql.DatabaseMetaData.importedKeyNoAction;
23442315
if ("cascade".equals(rule))
2345-
action = importedKeyCascade;
2316+
action = java.sql.DatabaseMetaData.importedKeyCascade;
23462317
else if ("setnull".equals(rule))
2347-
action = importedKeySetNull;
2318+
action = java.sql.DatabaseMetaData.importedKeySetNull;
23482319
else if ("setdefault".equals(rule))
2349-
action = importedKeySetDefault;
2320+
action = java.sql.DatabaseMetaData.importedKeySetDefault;
23502321
tuple[col] = Integer.toString(action).getBytes();
23512322

23522323
if (!foundRule)
@@ -2388,15 +2359,15 @@ else if ("setdefault".equals(rule))
23882359
tuple[12] = rs.getBytes(4); //PK_NAME
23892360

23902361
// DEFERRABILITY
2391-
int deferrability = importedKeyNotDeferrable;
2362+
int deferrability = java.sql.DatabaseMetaData.importedKeyNotDeferrable;
23922363
boolean deferrable = rs.getBoolean(5);
23932364
boolean initiallyDeferred = rs.getBoolean(6);
23942365
if (deferrable)
23952366
{
23962367
if (initiallyDeferred)
2397-
deferrability = importedKeyInitiallyDeferred;
2368+
deferrability = java.sql.DatabaseMetaData.importedKeyInitiallyDeferred;
23982369
else
2399-
deferrability = importedKeyInitiallyImmediate;
2370+
deferrability = java.sql.DatabaseMetaData.importedKeyInitiallyImmediate;
24002371
}
24012372
tuple[13] = Integer.toString(deferrability).getBytes();
24022373

@@ -2669,8 +2640,8 @@ public java.sql.ResultSet getTypeInfo() throws SQLException
26692640
byte b9[] = "9".getBytes();
26702641
byte b10[] = "10".getBytes();
26712642
byte bf[] = "f".getBytes();
2672-
byte bnn[] = Integer.toString(typeNoNulls).getBytes();
2673-
byte bts[] = Integer.toString(typeSearchable).getBytes();
2643+
byte bnn[] = Integer.toString(java.sql.DatabaseMetaData.typeNoNulls).getBytes();
2644+
byte bts[] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable).getBytes();
26742645

26752646
while (rs.next())
26762647
{
@@ -2811,10 +2782,10 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
28112782
tuple[4] = null;
28122783
tuple[5] = r.getBytes(3);
28132784
tuple[6] = r.getBoolean(4) ?
2814-
Integer.toString(tableIndexClustered).getBytes() :
2785+
Integer.toString(java.sql.DatabaseMetaData.tableIndexClustered).getBytes() :
28152786
r.getString(5).equals("hash") ?
2816-
Integer.toString(tableIndexHashed).getBytes() :
2817-
Integer.toString(tableIndexOther).getBytes();
2787+
Integer.toString(java.sql.DatabaseMetaData.tableIndexHashed).getBytes() :
2788+
Integer.toString(java.sql.DatabaseMetaData.tableIndexOther).getBytes();
28182789
tuple[7] = Integer.toString(i + 1).getBytes();
28192790
if (columnNameRS.next())
28202791
{

src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java renamed to src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11
package org.postgresql.jdbc1;
22

3-
// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
4-
// If you make any modifications to this file, you must make sure that the
5-
// changes are also made (if relevent) to the related JDBC 2 class in the
6-
// org.postgresql.jdbc2 package.
73

84
import java.lang.*;
95
import java.util.*;
106
import org.postgresql.*;
117
import org.postgresql.util.*;
12-
13-
// We explicitly import classes here as the original line:
14-
//import java.sql.*;
15-
// causes javac to get confused.
168
import java.sql.SQLException;
179
import java.sql.Types;
1810

19-
/*
20-
* A ResultSetMetaData object can be used to find out about the types and
21-
* properties of the columns in a ResultSet
22-
*
23-
* @see java.sql.ResultSetMetaData
24-
*/
25-
public class ResultSetMetaData implements java.sql.ResultSetMetaData
11+
public abstract class AbstractJdbc1ResultSetMetaData
2612
{
27-
Vector rows;
28-
Field[] fields;
13+
protected Vector rows;
14+
protected Field[] fields;
2915

3016
/*
3117
* Initialise for a result with a tuple set and
@@ -34,7 +20,7 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
3420
* @param rows the Vector of rows returned by the ResultSet
3521
* @param fields the array of field descriptors
3622
*/
37-
public ResultSetMetaData(Vector rows, Field[] fields)
23+
public AbstractJdbc1ResultSetMetaData(Vector rows, Field[] fields)
3824
{
3925
this.rows = rows;
4026
this.fields = fields;
@@ -149,7 +135,7 @@ public int isNullable(int column) throws SQLException
149135
* defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
150136
* functions etc.
151137
*/
152-
return columnNullableUnknown;
138+
return java.sql.ResultSetMetaData.columnNullableUnknown;
153139
}
154140

155141
/*

src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1Connection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.postgresql.Field;
77
import org.postgresql.util.PSQLException;
88

9-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.3 2002/07/25 22:45:28 barry Exp $
9+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.4 2002/07/26 05:29:35 barry Exp $
1010
* This class implements the java.sql.Connection interface for JDBC1.
1111
* However most of the implementation is really done in
1212
* org.postgresql.jdbc1.AbstractJdbc1Connection
@@ -32,7 +32,7 @@ public java.sql.CallableStatement prepareCall(String sql) throws SQLException
3232
public java.sql.DatabaseMetaData getMetaData() throws SQLException
3333
{
3434
if (metadata == null)
35-
metadata = new org.postgresql.jdbc1.DatabaseMetaData(this);
35+
metadata = new org.postgresql.jdbc1.Jdbc1DatabaseMetaData(this);
3636
return metadata;
3737
}
3838

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.postgresql.jdbc1;
2+
3+
4+
import java.sql.*;
5+
import java.util.*;
6+
import org.postgresql.Field;
7+
import org.postgresql.util.PSQLException;
8+
9+
public class Jdbc1DatabaseMetaData extends AbstractJdbc1DatabaseMetaData implements java.sql.DatabaseMetaData
10+
{
11+
public Jdbc1DatabaseMetaData(Jdbc1Connection conn)
12+
{
13+
super(conn);
14+
}
15+
16+
}

src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.Vector;
66
import org.postgresql.Field;
77

8-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.2 2002/07/25 22:45:28 barry Exp $
8+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.3 2002/07/26 05:29:35 barry Exp $
99
* This class implements the java.sql.ResultSet interface for JDBC1.
1010
* However most of the implementation is really done in
1111
* org.postgresql.jdbc1.AbstractJdbc1ResultSet
@@ -20,7 +20,7 @@ public Jdbc1ResultSet(Jdbc1Connection conn, Statement statement, Field[] fields,
2020

2121
public java.sql.ResultSetMetaData getMetaData() throws SQLException
2222
{
23-
return new ResultSetMetaData(rows, fields);
23+
return new Jdbc1ResultSetMetaData(rows, fields);
2424
}
2525

2626
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.postgresql.jdbc1;
2+
3+
public class Jdbc1ResultSetMetaData extends AbstractJdbc1ResultSetMetaData implements java.sql.ResultSetMetaData
4+
{
5+
public Jdbc1ResultSetMetaData(java.util.Vector rows, org.postgresql.Field[] fields)
6+
{
7+
super(rows, fields);
8+
}
9+
10+
}
11+

0 commit comments

Comments
 (0)