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

Commit24c8283

Browse files
author
Peter Mount
committed
Patches for 6.5.2
1 parent4197aaa commit24c8283

File tree

11 files changed

+203
-131
lines changed

11 files changed

+203
-131
lines changed

‎src/interfaces/jdbc/CHANGELOG

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Mon Sep 13 23:56:00 BST 1999 peter@retep.org.uk
2+
- PG_Stream.SendChar() optimised, increased default buffer size of
3+
output stream to 8k, and introduced an 8k buffer on the input stream
4+
Sverre H Huseby <sverrehu@online.no>
5+
- Added a finalize() method to Connection class in both drivers so that
6+
the connection to the backend is really closed.
7+
- Due to many JVM's not returning a meaningful value for java.version
8+
the decision for building the JDBC1.2 or JDBC2 driver is now a
9+
compile time option.
10+
- Replaced $$(cmd...) with `cmd...` in the Makefile. This should allow
11+
the driver to compile when using shells other than Bash.
12+
13+
Sun Aug 1 18:05:42 CEST 1999 jens@jens.de
14+
- added support for getTransactionIsolation and setTransactionIsolation
15+
116
Sun Jun 27 12:00:00 BST 1999
217
- Fixed typo in postgresql.Driver that prevented compilation
318
- Implemented getTimestamp() fix submitted by Philipp Matthias Hahn

‎src/interfaces/jdbc/Makefile

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for Java JDBC interface
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.14 1999/06/23 05:56:17 peter Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.15 1999/09/14 05:50:27 peter Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
FIND= find
1212
IDL2JAVA= idltojava -fno-cpp -fno-tie
1313
JAR= jar
1414
JAVA= java
15-
JAVAC= javac
15+
JAVAC= javac -g
1616
JAVADOC= javadoc
1717
RM= rm -f
1818
TOUCH= touch
@@ -22,12 +22,26 @@ TOUCH= touch
2222
$(JAVAC)$<
2323

2424
.SUFFIXES:.class .java
25-
.PHONY:all clean doc examples
25+
.PHONY:all clean doc examples msg
2626

2727
# In 6.5, the all rule builds the makeVersion class which then calls make using
2828
# the jdbc1 or jdbc2 rules
29-
all:makeVersion.class
30-
make$$($(JAVA) makeVersion)
29+
all:
30+
@echo ------------------------------------------------------------
31+
@echo Due to problems with some JVMs that dontreturn a meaningful
32+
@echo version number, we have had to make the choice of what jdbc
33+
@echo version is built as a compiletime option.
34+
@echo
35+
@echo If you are using JDK1.1.x, you will need the JDBC1.2 driver.
36+
@echo To compile, type:
37+
@echo" make jdbc1"
38+
@echo
39+
@echo"If you are using JDK1.2 (aka Java2) you need the JDBC2."
40+
@echo To compile, type:
41+
@echo" make jdbc2"
42+
@echo ------------------------------------------------------------
43+
44+
msg:
3145
@echo ------------------------------------------------------------
3246
@echo The JDBC driver has now been built. To make it available to
3347
@echo other applications, copy the postgresql.jar file to a public
@@ -107,34 +121,29 @@ OBJ_JDBC2=postgresql/jdbc2/ResultSet.class \
107121
postgresql/jdbc2/ResultSetMetaData.class\
108122
postgresql/jdbc2/Statement.class
109123

110-
# This rule should never occur, but will be called when makeVersion fails to
111-
# understand the java.version property correctly.
112-
jdbc0:
113-
@echo
114-
@echo FATAL ERROR!
115-
@echo
116-
@echo makeVersion has not been able to determine what version of
117-
@echo the JDK you are using, and hence what version of the driver
118-
@echo to compile.
119-
@echo
120-
@echo There are two versions available, one that conforms to the
121-
@echo JDBC 1 specification, and one to the JDBC 2 specification.
122-
@echo
123-
@echo To build the driverfor JDBC 1 (usuallyfor JDK 1.1 thru 1.1.7)
124-
@echothen type: make jdbc1
125-
@echo
126-
@echo To build the driverfor JDBC 2 (usuallyfor JDK 1.2 and later)
127-
@echothen type: make jdbc2
128-
@echo
129-
@echo If you still have problems,then please email the interfaces
130-
@echo or bugs lists, or better still to me direct (peter@retep.org.uk)
131-
@echo
132-
133124
# This rule builds the JDBC1 compliant driver
134-
jdbc1:$(OBJ_COMMON)$(OBJ_JDBC1) postgresql.jar
125+
jdbc1:
126+
(echo"package postgresql;";\
127+
echo"public class DriverClass {";\
128+
echo"public static String connectClass=\"postgresql.jdbc1.Connection\";";\
129+
echo"}"\
130+
)>postgresql/DriverClass.java
131+
@$(MAKE) jdbc1real
132+
133+
jdbc2real: postgresql/DriverClass.class\
134+
$(OBJ_COMMON)$(OBJ_JDBC2) postgresql.jar msg
135135

136136
# This rule builds the JDBC2 compliant driver
137-
jdbc2:$(OBJ_COMMON)$(OBJ_JDBC2) postgresql.jar
137+
jdbc2:
138+
(echo"package postgresql;";\
139+
echo"public class DriverClass {";\
140+
echo"public static String connectClass=\"postgresql.jdbc2.Connection\";";\
141+
echo"}"\
142+
)>postgresql/DriverClass.java
143+
@$(MAKE) jdbc2real
144+
145+
jdbc2real: postgresql/DriverClass.class\
146+
$(OBJ_COMMON)$(OBJ_JDBC2) postgresql.jar msg
138147

139148
# If you have problems with this rule, replace the $( ) with ` ` as some
140149
# shells (mainly sh under Solaris) doesn't recognise $( )
@@ -143,7 +152,7 @@ jdbc2:$(OBJ_COMMON) $(OBJ_JDBC2) postgresql.jar
143152
#directory. We use this later for compiling the dual-mode driver.
144153
#
145154
postgresql.jar:$(OBJ)$(OBJ_COMMON)
146-
$(JAR) -c0f$@$$($(FIND) postgresql -name "*.class" -print)\
155+
$(JAR) -c0f$@`$(FIND) postgresql -name"*.class" -print`\
147156
$(wildcard postgresql/*.properties)
148157

149158
# This rule removes any temporary and compiled files from the source tree.

‎src/interfaces/jdbc/makeVersion.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎src/interfaces/jdbc/postgresql/Connection.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
importpostgresql.util.*;
1111

1212
/**
13-
* $Id: Connection.java,v 1.17 1999/05/18 23:17:15 peter Exp $
13+
* $Id: Connection.java,v 1.18 1999/09/14 05:50:33 peter Exp $
1414
*
1515
* This abstract class is used by postgresql.Driver to open either the JDBC1 or
1616
* JDBC2 versions of the Connection class.
@@ -692,4 +692,17 @@ private void initObjectTypes()
692692
* version (from jdbc1 or jdbc2) are returned.
693693
*/
694694
protectedabstractjava.sql.ResultSetgetResultSet(postgresql.Connectionconn,Field[]fields,Vectortuples,Stringstatus,intupdateCount)throwsSQLException;
695+
696+
/**
697+
* Overides finalize(). If called, it closes the connection.
698+
*
699+
* This was done at the request of Rachel Greenham
700+
* <rachel@enlarion.demon.co.uk> who hit a problem where multiple
701+
* clients didn't close the connection, and once a fortnight enough
702+
* clients were open to kill the postgres server.
703+
*/
704+
publicvoidfinalize()throwsThrowable
705+
{
706+
close();
707+
}
695708
}

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public class Driver implements java.sql.Driver
3131
staticfinalintMAJORVERSION =6;
3232
staticfinalintMINORVERSION =5;
3333

34-
// Cache the version of the JDK in use
35-
staticStringconnectClass;
36-
3734
static
3835
{
3936
try {
@@ -56,11 +53,27 @@ public Driver() throws SQLException
5653
{
5754
// Set the connectClass variable so that future calls will handle the correct
5855
// base class
59-
if(System.getProperty("java.version").startsWith("1.1")) {
60-
connectClass ="postgresql.jdbc1.Connection";
61-
}else {
62-
connectClass ="postgresql.jdbc2.Connection";
63-
}
56+
//if(System.getProperty("java.version").startsWith("1.1")) {
57+
//connectClass = "postgresql.jdbc1.Connection";
58+
//} else {
59+
//connectClass = "postgresql.jdbc2.Connection";
60+
//}
61+
62+
// Ok, when the above code was introduced in 6.5 it's intention was to allow
63+
// the driver to automatically detect which version of JDBC was being used
64+
// and to detect the version of the JVM accordingly.
65+
//
66+
// It did this by using the java.version parameter.
67+
//
68+
// However, it was quickly discovered that not all JVM's returned an easily
69+
// parseable version number (ie "1.2") and some don't return a value at all.
70+
// The latter came from a discussion on the advanced java list.
71+
//
72+
// So, to solve this, I've moved the decision out of the driver, and it's now
73+
// a compile time parameter.
74+
//
75+
// For this to work, the Makefile creates a pseudo class which contains the class
76+
// name that will actually make the connection.
6477
}
6578

6679
/**
@@ -96,10 +109,10 @@ public java.sql.Connection connect(String url, Properties info) throws SQLExcept
96109
if((props =parseURL(url,info))==null)
97110
returnnull;
98111

99-
DriverManager.println("Using "+connectClass);
112+
DriverManager.println("Using "+DriverClass.connectClass);
100113

101114
try {
102-
postgresql.Connectioncon = (postgresql.Connection)(Class.forName(connectClass).newInstance());
115+
postgresql.Connectioncon = (postgresql.Connection)(Class.forName(DriverClass.connectClass).newInstance());
103116
con.openConnection (host(),port(),props,database(),url,this);
104117
return (java.sql.Connection)con;
105118
}catch(ClassNotFoundExceptionex) {
@@ -302,8 +315,10 @@ else if (state == -5) {
302315

303316
// PM June 29 1997
304317
// This now outputs the properties only if we are logging
305-
if(DriverManager.getLogStream() !=null)
306-
urlProps.list(DriverManager.getLogStream());
318+
// PM Sep 13 1999 Commented out, as it throws a Deprecation warning
319+
// when compiled under JDK1.2.
320+
//if(DriverManager.getLogStream() != null)
321+
// urlProps.list(DriverManager.getLogStream());
307322

308323
returnurlProps;
309324

‎src/interfaces/jdbc/postgresql/PG_Stream.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public PG_Stream(String host, int port) throws IOException
3939
// improvement on FreeBSD machines (caused by a bug in their TCP Stack)
4040
connection.setTcpNoDelay(true);
4141

42-
pg_input =connection.getInputStream();
43-
pg_output =newBufferedOutputStream(connection.getOutputStream());
42+
// Buffer sizes submitted by Sverre H Huseby <sverrehu@online.no>
43+
pg_input =newBufferedInputStream(connection.getInputStream(),8192);
44+
pg_output =newBufferedOutputStream(connection.getOutputStream(),8192);
4445
}
4546

4647
/**
@@ -51,9 +52,13 @@ public PG_Stream(String host, int port) throws IOException
5152
*/
5253
publicvoidSendChar(intval)throwsIOException
5354
{
54-
byteb[] =newbyte[1];
55-
b[0] = (byte)val;
56-
pg_output.write(b);
55+
// Original code
56+
//byte b[] = new byte[1];
57+
//b[0] = (byte)val;
58+
//pg_output.write(b);
59+
60+
// Optimised version by Sverre H. Huseby Aug 22 1999 Applied Sep 13 1999
61+
pg_output.write((byte)val);
5762
}
5863

5964
/**

‎src/interfaces/jdbc/postgresql/errors.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ postgresql.con.refused:Connection refused. Check that the hostname and port is c
1515
postgresql.con.strobj:The object could not be stored. Check that any tables required have already been created in the database.
1616
postgresql.con.strobjex:Failed to store object - {0}
1717
postgresql.con.toolong:The SQL Statement is too long - {0}
18+
postgresql.con.isolevel:Transaction isolation level {0} is not supported.
1819
postgresql.con.tuple:Tuple received before MetaData.
1920
postgresql.con.type:Unknown Response Type {0}
2021
postgresql.con.user:The user property is missing. It is mandatory.

‎src/interfaces/jdbc/postgresql/jdbc1/Connection.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
importpostgresql.util.*;
1818

1919
/**
20-
* $Id: Connection.java,v 1.2 1999/05/18 23:17:21 peter Exp $
20+
* $Id: Connection.java,v 1.3 1999/09/14 05:50:39 peter Exp $
2121
*
2222
* A Connection represents a session with a specific database. Within the
2323
* context of a Connection, SQL statements are executed and results are
@@ -216,7 +216,7 @@ public void close() throws SQLException
216216
pg_stream =null;
217217
}
218218
}
219-
219+
220220
/**
221221
* Tests to see if a Connection is closed
222222
*
@@ -311,9 +311,23 @@ public String getCatalog() throws SQLException
311311
*/
312312
publicvoidsetTransactionIsolation(intlevel)throwsSQLException
313313
{
314-
throwpostgresql.Driver.notImplemented();
314+
Stringq ="SET TRANSACTION ISOLATION LEVEL";
315+
316+
switch(level) {
317+
318+
casejava.sql.Connection.TRANSACTION_READ_COMMITTED:
319+
ExecSQL(q +" READ COMMITTED");
320+
return;
321+
322+
casejava.sql.Connection.TRANSACTION_SERIALIZABLE:
323+
ExecSQL(q +" SERIALIZABLE");
324+
return;
325+
326+
default:
327+
thrownewPSQLException("postgresql.con.isolevel",newInteger(level));
328+
}
315329
}
316-
330+
317331
/**
318332
* Get this Connection's current transaction isolation mode.
319333
*
@@ -322,9 +336,18 @@ public void setTransactionIsolation(int level) throws SQLException
322336
*/
323337
publicintgetTransactionIsolation()throwsSQLException
324338
{
325-
returnjava.sql.Connection.TRANSACTION_SERIALIZABLE;
339+
ExecSQL("show xactisolevel");
340+
341+
SQLWarningw =getWarnings();
342+
if (w !=null) {
343+
if (w.getMessage().indexOf("READ COMMITTED") != -1)returnjava.sql.Connection.TRANSACTION_READ_COMMITTED;else
344+
if (w.getMessage().indexOf("READ UNCOMMITTED") != -1)returnjava.sql.Connection.TRANSACTION_READ_UNCOMMITTED;else
345+
if (w.getMessage().indexOf("REPEATABLE READ") != -1)returnjava.sql.Connection.TRANSACTION_REPEATABLE_READ;else
346+
if (w.getMessage().indexOf("SERIALIZABLE") != -1)returnjava.sql.Connection.TRANSACTION_SERIALIZABLE;
347+
}
348+
returnjava.sql.Connection.TRANSACTION_READ_COMMITTED;
326349
}
327-
350+
328351
/**
329352
* The first warning reported by calls on this Connection is
330353
* returned.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp