1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

Back out Gunnar R|nning jdbc changes.

This commit is contained in:
Bruce Momjian
2000-10-09 16:48:19 +00:00
parent c4ccc6146b
commit a4e3943b3f
13 changed files with 84 additions and 412 deletions

View File

@ -10,7 +10,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/**
* $Id: Connection.java,v 1.7 2000/10/08 19:37:54 momjian Exp $
* $Id: Connection.java,v 1.8 2000/10/09 16:48:16 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@ -81,11 +81,6 @@ public abstract class Connection
// The PID an cancellation key we get from the backend process
public int pid;
public int ckey;
// This receive_sbuf should be used by the different methods
// that call pg_stream.ReceiveString() in this Connection, so
// so we avoid uneccesary new allocations.
byte receive_sbuf[] = new byte[8192];
/**
* This is called by Class.forName() from within org.postgresql.Driver
@ -169,9 +164,8 @@ public abstract class Connection
// The most common one to be thrown here is:
// "User authentication failed"
//
String msg = pg_stream.ReceiveString(receive_sbuf, 4096,
getEncoding());
throw new SQLException(msg);
throw new SQLException(pg_stream.ReceiveString
(4096, getEncoding()));
case 'R':
// Get the type of request
@ -242,7 +236,7 @@ public abstract class Connection
case 'E':
case 'N':
throw new SQLException(pg_stream.ReceiveString
(receive_sbuf, 4096, getEncoding()));
(4096, getEncoding()));
default:
throw new PSQLException("postgresql.con.setup");
}
@ -254,7 +248,7 @@ public abstract class Connection
break;
case 'E':
case 'N':
throw new SQLException(pg_stream.ReceiveString(receive_sbuf, 4096, getEncoding()));
throw new SQLException(pg_stream.ReceiveString(4096));
default:
throw new PSQLException("postgresql.con.setup");
}
@ -269,7 +263,7 @@ public abstract class Connection
//
firstWarning = null;
ExecSQL(null, "set datestyle to 'ISO'");
ExecSQL("set datestyle to 'ISO'");
// Initialise object handling
initObjectTypes();
@ -312,8 +306,7 @@ public abstract class Connection
//currentDateStyle=i+1; // this is the index of the format
//}
}
/**
* Send a query to the backend. Returns one of the ResultSet
* objects.
@ -321,18 +314,15 @@ public abstract class Connection
* <B>Note:</B> there does not seem to be any method currently
* in existance to return the update count.
*
* @param stmt The statment object.
* @param sql the SQL statement to be executed
* @return a ResultSet holding the results
* @exception SQLException if a database error occurs
*/
public java.sql.ResultSet ExecSQL(PGStatement stmt,
String sql) throws SQLException
public java.sql.ResultSet ExecSQL(String sql) throws SQLException
{
// added Oct 7 1998 to give us thread safety.
synchronized(pg_stream) {
pg_stream.setExecutingStatement(stmt);
Field[] fields = null;
Vector tuples = new Vector();
byte[] buf = null;
@ -362,7 +352,8 @@ public abstract class Connection
try
{
pg_stream.SendChar('Q');
pg_stream.Send(sql.getBytes());
buf = sql.getBytes();
pg_stream.Send(buf);
pg_stream.SendChar(0);
pg_stream.flush();
} catch (IOException e) {
@ -379,8 +370,7 @@ public abstract class Connection
{
case 'A': // Asynchronous Notify
pid = pg_stream.ReceiveInteger(4);
msg = pg_stream.ReceiveString(receive_sbuf, 8192,
getEncoding());
msg = pg_stream.ReceiveString(8192);
break;
case 'B': // Binary Data Transfer
if (fields == null)
@ -391,9 +381,7 @@ public abstract class Connection
tuples.addElement(tup);
break;
case 'C': // Command Status
recv_status =
pg_stream.ReceiveString(receive_sbuf, 8192,
getEncoding());
recv_status = pg_stream.ReceiveString(8192);
// Now handle the update count correctly.
if(recv_status.startsWith("INSERT") || recv_status.startsWith("UPDATE") || recv_status.startsWith("DELETE")) {
@ -435,8 +423,7 @@ public abstract class Connection
tuples.addElement(tup);
break;
case 'E': // Error Message
msg = pg_stream.ReceiveString(receive_sbuf, 4096,
getEncoding());
msg = pg_stream.ReceiveString(4096);
final_error = new SQLException(msg);
hfr = true;
break;
@ -451,14 +438,10 @@ public abstract class Connection
hfr = true;
break;
case 'N': // Error Notification
addWarning(pg_stream.ReceiveString(receive_sbuf,
4096,
getEncoding()));
addWarning(pg_stream.ReceiveString(4096));
break;
case 'P': // Portal Name
String pname =
pg_stream.ReceiveString(receive_sbuf, 8192,
getEncoding());
String pname = pg_stream.ReceiveString(8192);
break;
case 'T': // MetaData Field Description
if (fields != null)
@ -478,8 +461,6 @@ public abstract class Connection
}
}
/**
* Receive the field descriptions from the back end
*
@ -493,8 +474,7 @@ public abstract class Connection
for (i = 0 ; i < nf ; ++i)
{
String typname = pg_stream.ReceiveString(receive_sbuf, 8192,
getEncoding());
String typname = pg_stream.ReceiveString(8192);
int typid = pg_stream.ReceiveIntegerR(4);
int typlen = pg_stream.ReceiveIntegerR(2);
int typmod = pg_stream.ReceiveIntegerR(4);