@ -10,7 +10,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.* ;
import org.postgresql.util.* ;
/ * *
/ * *
* $Id : Connection . java , v 1 . 17 2001 / 06 / 07 00 : 09 : 32 momjian Exp $
* $Id : Connection . java , v 1 . 18 2001 / 07 / 15 04 : 21 : 26 momjian Exp $
*
*
* This abstract class is used by org . postgresql . Driver to open either the JDBC1 or
* This abstract class is used by org . postgresql . Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class .
* JDBC2 versions of the Connection class .
@ -82,11 +82,6 @@ public abstract class Connection
public int pid ;
public int pid ;
public int ckey ;
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
* This is called by Class . forName ( ) from within org . postgresql . Driver
* /
* /
@ -167,8 +162,7 @@ public abstract class Connection
// The most common one to be thrown here is:
// The most common one to be thrown here is:
// "User authentication failed"
// "User authentication failed"
//
//
throw new SQLException ( pg_stream . ReceiveString
throw new SQLException ( pg_stream . ReceiveString ( getEncoding ( ) ) ) ;
( receive_sbuf , 4096 , getEncoding ( ) ) ) ;
case 'R' :
case 'R' :
// Get the type of request
// Get the type of request
@ -238,8 +232,7 @@ public abstract class Connection
break ;
break ;
case 'E' :
case 'E' :
case 'N' :
case 'N' :
throw new SQLException ( pg_stream . ReceiveString
throw new SQLException ( pg_stream . ReceiveString ( getEncoding ( ) ) ) ;
( receive_sbuf , 4096 , getEncoding ( ) ) ) ;
default :
default :
throw new PSQLException ( "postgresql.con.setup" ) ;
throw new PSQLException ( "postgresql.con.setup" ) ;
}
}
@ -251,7 +244,7 @@ public abstract class Connection
break ;
break ;
case 'E' :
case 'E' :
case 'N' :
case 'N' :
throw new SQLException ( pg_stream . ReceiveString ( receive_sbuf , 4096 , getEncoding ( ) ) ) ;
throw new SQLException ( pg_stream . ReceiveString ( getEncoding ( ) ) ) ;
default :
default :
throw new PSQLException ( "postgresql.con.setup" ) ;
throw new PSQLException ( "postgresql.con.setup" ) ;
}
}
@ -491,7 +484,7 @@ public abstract class Connection
{
{
case 'A' : // Asynchronous Notify
case 'A' : // Asynchronous Notify
pid = pg_stream . ReceiveInteger ( 4 ) ;
pid = pg_stream . ReceiveInteger ( 4 ) ;
msg = pg_stream . ReceiveString ( receive_sbuf , 8192 , getEncoding ( ) ) ;
msg = pg_stream . ReceiveString ( getEncoding ( ) ) ;
break ;
break ;
case 'B' : // Binary Data Transfer
case 'B' : // Binary Data Transfer
if ( fields = = null )
if ( fields = = null )
@ -502,7 +495,7 @@ public abstract class Connection
tuples . addElement ( tup ) ;
tuples . addElement ( tup ) ;
break ;
break ;
case 'C' : // Command Status
case 'C' : // Command Status
recv_status = pg_stream . ReceiveString ( receive_sbuf , 8192 , getEncoding ( ) ) ;
recv_status = pg_stream . ReceiveString ( getEncoding ( ) ) ;
// Now handle the update count correctly.
// Now handle the update count correctly.
if ( recv_status . startsWith ( "INSERT" ) | | recv_status . startsWith ( "UPDATE" ) | | recv_status . startsWith ( "DELETE" ) | | recv_status . startsWith ( "MOVE" ) ) {
if ( recv_status . startsWith ( "INSERT" ) | | recv_status . startsWith ( "UPDATE" ) | | recv_status . startsWith ( "DELETE" ) | | recv_status . startsWith ( "MOVE" ) ) {
@ -544,7 +537,7 @@ public abstract class Connection
tuples . addElement ( tup ) ;
tuples . addElement ( tup ) ;
break ;
break ;
case 'E' : // Error Message
case 'E' : // Error Message
msg = pg_stream . ReceiveString ( receive_sbuf , 4096 , getEncoding ( ) ) ;
msg = pg_stream . ReceiveString ( getEncoding ( ) ) ;
final_error = new SQLException ( msg ) ;
final_error = new SQLException ( msg ) ;
hfr = true ;
hfr = true ;
break ;
break ;
@ -559,10 +552,10 @@ public abstract class Connection
hfr = true ;
hfr = true ;
break ;
break ;
case 'N' : // Error Notification
case 'N' : // Error Notification
addWarning ( pg_stream . ReceiveString ( receive_sbuf , 4096 , getEncoding ( ) ) ) ;
addWarning ( pg_stream . ReceiveString ( getEncoding ( ) ) ) ;
break ;
break ;
case 'P' : // Portal Name
case 'P' : // Portal Name
String pname = pg_stream . ReceiveString ( receive_sbuf , 8192 , getEncoding ( ) ) ;
String pname = pg_stream . ReceiveString ( getEncoding ( ) ) ;
break ;
break ;
case 'T' : // MetaData Field Description
case 'T' : // MetaData Field Description
if ( fields ! = null )
if ( fields ! = null )
@ -595,7 +588,7 @@ public abstract class Connection
for ( i = 0 ; i < nf ; + + i )
for ( i = 0 ; i < nf ; + + i )
{
{
String typname = pg_stream . ReceiveString ( receive_sbuf , 8192 , getEncoding ( ) ) ;
String typname = pg_stream . ReceiveString ( getEncoding ( ) ) ;
int typid = pg_stream . ReceiveIntegerR ( 4 ) ;
int typid = pg_stream . ReceiveIntegerR ( 4 ) ;
int typlen = pg_stream . ReceiveIntegerR ( 2 ) ;
int typlen = pg_stream . ReceiveIntegerR ( 2 ) ;
int typmod = pg_stream . ReceiveIntegerR ( 4 ) ;
int typmod = pg_stream . ReceiveIntegerR ( 4 ) ;