Commit 25b5faa7 authored by Bruce Momjian's avatar Bruce Momjian

Just a quick patch. This makes the JDBC driver thread safe, which is an

important step towards making the driver compliant, and means that for
some Java applications and servlets, only a single database connection
is
needed, so in a sence this is a nice little show stopper for 6.4 (and
should still be backward compatible to 6.3.2).

Peter
parent 9042e9d7
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for Java JDBC interface # Makefile for Java JDBC interface
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.9 1998/09/03 02:29:41 momjian Exp $ # $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.10 1998/10/08 00:38:18 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -137,7 +137,8 @@ EX= example/basic.class \ ...@@ -137,7 +137,8 @@ EX= example/basic.class \
example/datestyle.class \ example/datestyle.class \
example/psql.class \ example/psql.class \
example/ImageViewer.class \ example/ImageViewer.class \
example/metadata.class example/metadata.class \
example/threadsafe.class
# example/Objects.class # example/Objects.class
# This rule builds the examples # This rule builds the examples
...@@ -160,7 +161,9 @@ examples: postgresql.jar $(EX) ...@@ -160,7 +161,9 @@ examples: postgresql.jar $(EX)
@echo " example.psql Simple java implementation of psql" @echo " example.psql Simple java implementation of psql"
@echo " example.Objects Demonstrates Object Serialisation" @echo " example.Objects Demonstrates Object Serialisation"
@echo " " @echo " "
@echo These are not really examples, but tests various parts of the driver
@echo " example.metadata Tests various metadata methods" @echo " example.metadata Tests various metadata methods"
@echo " example.threadsafe Tests the driver's thread safety"
@echo ------------------------------------------------------------ @echo ------------------------------------------------------------
@echo @echo
...@@ -170,6 +173,6 @@ example/datestyle.class: example/datestyle.java ...@@ -170,6 +173,6 @@ example/datestyle.class: example/datestyle.java
example/psql.class: example/psql.java example/psql.class: example/psql.java
example/ImageViewer.class: example/ImageViewer.java example/ImageViewer.class: example/ImageViewer.java
#example/Objects.class: example/Objects.java #example/Objects.class: example/Objects.java
example/threadsafe.class: example/threadsafe.java
example/metadata.class: example/metadata.java example/metadata.class: example/metadata.java
####################################################################### #######################################################################
This diff is collapsed.
...@@ -635,8 +635,11 @@ public class Connection implements java.sql.Connection ...@@ -635,8 +635,11 @@ public class Connection implements java.sql.Connection
* @return a ResultSet holding the results * @return a ResultSet holding the results
* @exception SQLException if a database error occurs * @exception SQLException if a database error occurs
*/ */
public synchronized ResultSet ExecSQL(String sql) throws SQLException public ResultSet ExecSQL(String sql) throws SQLException
{ {
// added Oct 7 1998 to give us thread safety.
synchronized(pg_stream) {
Field[] fields = null; Field[] fields = null;
Vector tuples = new Vector(); Vector tuples = new Vector();
byte[] buf = new byte[sql.length()]; byte[] buf = new byte[sql.length()];
...@@ -738,6 +741,7 @@ public class Connection implements java.sql.Connection ...@@ -738,6 +741,7 @@ public class Connection implements java.sql.Connection
throw final_error; throw final_error;
return new ResultSet(this, fields, tuples, recv_status, 1); return new ResultSet(this, fields, tuples, recv_status, 1);
} }
}
/** /**
* Receive the field descriptions from the back end * Receive the field descriptions from the back end
......
...@@ -68,6 +68,9 @@ public class Fastpath ...@@ -68,6 +68,9 @@ public class Fastpath
*/ */
public Object fastpath(int fnid,boolean resulttype,FastpathArg[] args) throws SQLException public Object fastpath(int fnid,boolean resulttype,FastpathArg[] args) throws SQLException
{ {
// added Oct 7 1998 to give us thread safety
synchronized(stream) {
// send the function call // send the function call
try { try {
// 70 is 'F' in ASCII. Note: don't use SendChar() here as it adds padding // 70 is 'F' in ASCII. Note: don't use SendChar() here as it adds padding
...@@ -154,6 +157,7 @@ public class Fastpath ...@@ -154,6 +157,7 @@ public class Fastpath
} }
} }
} }
}
/** /**
* Send a function call to the PostgreSQL backend by name. * Send a function call to the PostgreSQL backend by name.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment