Commit 0378a269 authored by Barry Lind's avatar Barry Lind

This set of changes applies a patch from KHO at redhat to add some SQLState

support to the jdbc driver.
That patch needed some work: it assumed the sqlcode in a server message was
fixed in its position, the patch lost the ability to pass exceptions, and the
patch missed a couple of places where server errors where being received.
In addition to fixing the above, I also added full support for the V3 protocol
error message syntax, I reversed the order of arguments in the PSQLException
constructor to more closely follow the constructors for SQLException, I changed
the new constructors that take PSQLState to take Object for additional
parameters as the old ones did.
Still todo are to add SQLState values to all existing exceptions thrown in the
driver and add support for parsing the V3 protocol format for notices.

 Modified Files:
 	jdbc/build.xml jdbc/org/postgresql/Driver.java.in
 	jdbc/org/postgresql/errors.properties
 	jdbc/org/postgresql/core/Encoding.java
 	jdbc/org/postgresql/core/PGStream.java
 	jdbc/org/postgresql/core/QueryExecutor.java
 	jdbc/org/postgresql/fastpath/Fastpath.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
 	jdbc/org/postgresql/util/MessageTranslator.java
 	jdbc/org/postgresql/util/PSQLException.java
parent e702b04c
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.34 2003/07/24 00:30:38 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.35 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,6 +17,7 @@ import java.sql.*; ...@@ -17,6 +17,7 @@ import java.sql.*;
import java.util.*; import java.util.*;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
/* /*
* The Java SQL framework allows for multiple database drivers. Each * The Java SQL framework allows for multiple database drivers. Each
...@@ -419,7 +420,7 @@ public class Driver implements java.sql.Driver ...@@ -419,7 +420,7 @@ public class Driver implements java.sql.Driver
*/ */
public static SQLException notImplemented() public static SQLException notImplemented()
{ {
return new PSQLException("postgresql.unimplemented"); return new PSQLException("postgresql.unimplemented", PSQLState.NOT_IMPLEMENTED);
} }
/** /**
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Encoding.java,v 1.11 2003/05/29 03:21:32 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Encoding.java,v 1.12 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -19,6 +19,7 @@ import java.io.UnsupportedEncodingException; ...@@ -19,6 +19,7 @@ import java.io.UnsupportedEncodingException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Hashtable; import java.util.Hashtable;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
public class Encoding public class Encoding
{ {
...@@ -160,7 +161,7 @@ public class Encoding ...@@ -160,7 +161,7 @@ public class Encoding
} }
catch (UnsupportedEncodingException e) catch (UnsupportedEncodingException e)
{ {
throw new PSQLException("postgresql.stream.encoding", e); throw new PSQLException("postgresql.stream.encoding", PSQLState.DATA_ERROR, e);
} }
} }
...@@ -185,7 +186,7 @@ public class Encoding ...@@ -185,7 +186,7 @@ public class Encoding
} }
catch (UnsupportedEncodingException e) catch (UnsupportedEncodingException e)
{ {
throw new PSQLException("postgresql.stream.encoding", e); throw new PSQLException("postgresql.stream.encoding", PSQLState.DATA_ERROR, e);
} }
} }
...@@ -215,7 +216,7 @@ public class Encoding ...@@ -215,7 +216,7 @@ public class Encoding
} }
catch (UnsupportedEncodingException e) catch (UnsupportedEncodingException e)
{ {
throw new PSQLException("postgresql.res.encoding", e); throw new PSQLException("postgresql.res.encoding", PSQLState.DATA_ERROR, e);
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/PGStream.java,v 1.2 2003/05/29 03:21:32 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/PGStream.java,v 1.3 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,6 +20,7 @@ import java.io.IOException; ...@@ -20,6 +20,7 @@ import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import java.sql.*; import java.sql.*;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
public class PGStream public class PGStream
...@@ -164,11 +165,11 @@ public class PGStream ...@@ -164,11 +165,11 @@ public class PGStream
{ {
c = pg_input.read(); c = pg_input.read();
if (c < 0) if (c < 0)
throw new PSQLException("postgresql.stream.eof"); throw new PSQLException("postgresql.stream.eof", PSQLState.COMMUNICATION_ERROR);
} }
catch (IOException e) catch (IOException e)
{ {
throw new PSQLException("postgresql.stream.ioerror", e); throw new PSQLException("postgresql.stream.ioerror", PSQLState.COMMUNICATION_ERROR, e);
} }
return c; return c;
} }
...@@ -191,13 +192,13 @@ public class PGStream ...@@ -191,13 +192,13 @@ public class PGStream
int b = pg_input.read(); int b = pg_input.read();
if (b < 0) if (b < 0)
throw new PSQLException("postgresql.stream.eof"); throw new PSQLException("postgresql.stream.eof", PSQLState.COMMUNICATION_ERROR);
n = n | (b << (8 * i)) ; n = n | (b << (8 * i)) ;
} }
} }
catch (IOException e) catch (IOException e)
{ {
throw new PSQLException("postgresql.stream.ioerror", e); throw new PSQLException("postgresql.stream.ioerror", PSQLState.COMMUNICATION_ERROR, e);
} }
return n; return n;
} }
...@@ -220,13 +221,13 @@ public class PGStream ...@@ -220,13 +221,13 @@ public class PGStream
int b = pg_input.read(); int b = pg_input.read();
if (b < 0) if (b < 0)
throw new PSQLException("postgresql.stream.eof"); throw new PSQLException("postgresql.stream.eof", PSQLState.COMMUNICATION_ERROR);
n = b | (n << 8); n = b | (n << 8);
} }
} }
catch (IOException e) catch (IOException e)
{ {
throw new PSQLException("postgresql.stream.ioerror", e); throw new PSQLException("postgresql.stream.ioerror", PSQLState.COMMUNICATION_ERROR, e);
} }
return n; return n;
} }
...@@ -254,7 +255,7 @@ public class PGStream ...@@ -254,7 +255,7 @@ public class PGStream
{ {
int c = pg_input.read(); int c = pg_input.read();
if (c < 0) if (c < 0)
throw new PSQLException("postgresql.stream.eof"); throw new PSQLException("postgresql.stream.eof", PSQLState.COMMUNICATION_ERROR);
else if (c == 0) else if (c == 0)
{ {
rst[s] = 0; rst[s] = 0;
...@@ -277,7 +278,7 @@ public class PGStream ...@@ -277,7 +278,7 @@ public class PGStream
} }
catch (IOException e) catch (IOException e)
{ {
throw new PSQLException("postgresql.stream.ioerror", e); throw new PSQLException("postgresql.stream.ioerror", PSQLState.COMMUNICATION_ERROR, e);
} }
return encoding.decode(rst, 0, s); return encoding.decode(rst, 0, s);
} }
...@@ -389,13 +390,13 @@ public class PGStream ...@@ -389,13 +390,13 @@ public class PGStream
{ {
int w = pg_input.read(b, off + s, siz - s); int w = pg_input.read(b, off + s, siz - s);
if (w < 0) if (w < 0)
throw new PSQLException("postgresql.stream.eof"); throw new PSQLException("postgresql.stream.eof", PSQLState.COMMUNICATION_ERROR);
s += w; s += w;
} }
} }
catch (IOException e) catch (IOException e)
{ {
throw new PSQLException("postgresql.stream.ioerror", e); throw new PSQLException("postgresql.stream.ioerror", PSQLState.COMMUNICATION_ERROR, e);
} }
} }
...@@ -412,7 +413,7 @@ public class PGStream ...@@ -412,7 +413,7 @@ public class PGStream
} }
catch (IOException e) catch (IOException e)
{ {
throw new PSQLException("postgresql.stream.flush", e); throw new PSQLException("postgresql.stream.flush", PSQLState.COMMUNICATION_ERROR, e);
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.23 2003/08/11 21:18:47 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.24 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,6 +17,7 @@ import java.io.IOException; ...@@ -17,6 +17,7 @@ import java.io.IOException;
import java.sql.*; import java.sql.*;
import org.postgresql.Driver; import org.postgresql.Driver;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
public class QueryExecutor public class QueryExecutor
{ {
...@@ -108,11 +109,11 @@ public class QueryExecutor ...@@ -108,11 +109,11 @@ public class QueryExecutor
private BaseResultSet executeV3() throws SQLException private BaseResultSet executeV3() throws SQLException
{ {
StringBuffer errorMessage = null; PSQLException error = null;
if (pgStream == null) if (pgStream == null)
{ {
throw new PSQLException("postgresql.con.closed"); throw new PSQLException("postgresql.con.closed", PSQLState.CONNECTION_DOES_NOT_EXIST);
} }
synchronized (pgStream) synchronized (pgStream)
...@@ -148,11 +149,16 @@ public class QueryExecutor ...@@ -148,11 +149,16 @@ public class QueryExecutor
// so, append messages to a string buffer and keep processing // so, append messages to a string buffer and keep processing
// check at the bottom to see if we need to throw an exception // check at the bottom to see if we need to throw an exception
if ( errorMessage == null )
errorMessage = new StringBuffer();
int l_elen = pgStream.ReceiveIntegerR(4); int l_elen = pgStream.ReceiveIntegerR(4);
errorMessage.append(connection.getEncoding().decode(pgStream.Receive(l_elen-4))); String totalMessage = connection.getEncoding().decode(pgStream.Receive(l_elen-4));
PSQLException l_error = PSQLException.parseServerError(totalMessage);
if (error != null) {
error.setNextException(l_error);
} else {
error = l_error;
}
// keep processing // keep processing
break; break;
case 'I': // Empty Query case 'I': // Empty Query
...@@ -178,22 +184,20 @@ public class QueryExecutor ...@@ -178,22 +184,20 @@ public class QueryExecutor
case 'Z': case 'Z':
// read ReadyForQuery // read ReadyForQuery
//TODO: use size better //TODO: use size better
if (pgStream.ReceiveIntegerR(4) != 5) throw new PSQLException("postgresql.con.setup"); if (pgStream.ReceiveIntegerR(4) != 5) throw new PSQLException("postgresql.con.setup", PSQLState.CONNECTION_UNABLE_TO_CONNECT);
//TODO: handle transaction status //TODO: handle transaction status
char l_tStatus = (char)pgStream.ReceiveChar(); char l_tStatus = (char)pgStream.ReceiveChar();
l_endQuery = true; l_endQuery = true;
break; break;
default: default:
throw new PSQLException("postgresql.con.type", throw new PSQLException("postgresql.con.type", PSQLState.CONNECTION_FAILURE, new Character((char) c));
new Character((char) c));
} }
} }
// did we get an error during this query? // did we get an error during this query?
if ( errorMessage != null ) if ( error != null )
throw new SQLException( errorMessage.toString().trim() ); throw error;
//if an existing result set was passed in reuse it, else //if an existing result set was passed in reuse it, else
//create a new one //create a new one
...@@ -216,7 +220,7 @@ public class QueryExecutor ...@@ -216,7 +220,7 @@ public class QueryExecutor
if (pgStream == null) if (pgStream == null)
{ {
throw new PSQLException("postgresql.con.closed"); throw new PSQLException("postgresql.con.closed", PSQLState.CONNECTION_DOES_NOT_EXIST);
} }
synchronized (pgStream) synchronized (pgStream)
...@@ -275,8 +279,7 @@ public class QueryExecutor ...@@ -275,8 +279,7 @@ public class QueryExecutor
l_endQuery = true; l_endQuery = true;
break; break;
default: default:
throw new PSQLException("postgresql.con.type", throw new PSQLException("postgresql.con.type", PSQLState.CONNECTION_FAILURE, new Character((char) c));
new Character((char) c));
} }
} }
...@@ -308,7 +311,7 @@ public class QueryExecutor ...@@ -308,7 +311,7 @@ public class QueryExecutor
for ( int i = 0; i < m_binds.length ; i++ ) for ( int i = 0; i < m_binds.length ; i++ )
{ {
if ( m_binds[i] == null ) if ( m_binds[i] == null )
throw new PSQLException("postgresql.prep.param", new Integer(i + 1)); throw new PSQLException("postgresql.prep.param", PSQLState.PARAMETER_ERROR, new Integer(i + 1));
} }
try try
{ {
...@@ -349,7 +352,7 @@ public class QueryExecutor ...@@ -349,7 +352,7 @@ public class QueryExecutor
for ( int i = 0; i < m_binds.length ; i++ ) for ( int i = 0; i < m_binds.length ; i++ )
{ {
if ( m_binds[i] == null ) if ( m_binds[i] == null )
throw new PSQLException("postgresql.prep.param", new Integer(i + 1)); throw new PSQLException("postgresql.prep.param", PSQLState.PARAMETER_ERROR, new Integer(i + 1));
} }
try try
{ {
...@@ -379,7 +382,7 @@ public class QueryExecutor ...@@ -379,7 +382,7 @@ public class QueryExecutor
private void receiveTupleV3(boolean isBinary) throws SQLException private void receiveTupleV3(boolean isBinary) throws SQLException
{ {
if (fields == null) if (fields == null)
throw new PSQLException("postgresql.con.tuple"); throw new PSQLException("postgresql.con.tuple", PSQLState.CONNECTION_FAILURE);
Object tuple = pgStream.ReceiveTupleV3(fields.length, isBinary); Object tuple = pgStream.ReceiveTupleV3(fields.length, isBinary);
if (isBinary) if (isBinary)
binaryCursor = true; binaryCursor = true;
...@@ -395,7 +398,7 @@ public class QueryExecutor ...@@ -395,7 +398,7 @@ public class QueryExecutor
private void receiveTupleV2(boolean isBinary) throws SQLException private void receiveTupleV2(boolean isBinary) throws SQLException
{ {
if (fields == null) if (fields == null)
throw new PSQLException("postgresql.con.tuple"); throw new PSQLException("postgresql.con.tuple", PSQLState.CONNECTION_FAILURE);
Object tuple = pgStream.ReceiveTupleV2(fields.length, isBinary); Object tuple = pgStream.ReceiveTupleV2(fields.length, isBinary);
if (isBinary) if (isBinary)
binaryCursor = true; binaryCursor = true;
...@@ -429,7 +432,7 @@ public class QueryExecutor ...@@ -429,7 +432,7 @@ public class QueryExecutor
} }
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ {
throw new PSQLException("postgresql.con.fathom", status); throw new PSQLException("postgresql.con.fathom", PSQLState.CONNECTION_FAILURE, status);
} }
} }
/* /*
...@@ -455,7 +458,7 @@ public class QueryExecutor ...@@ -455,7 +458,7 @@ public class QueryExecutor
} }
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ {
throw new PSQLException("postgresql.con.fathom", status); throw new PSQLException("postgresql.con.fathom", PSQLState.CONNECTION_FAILURE, status);
} }
} }
...@@ -467,7 +470,7 @@ public class QueryExecutor ...@@ -467,7 +470,7 @@ public class QueryExecutor
//TODO: use the msgSize //TODO: use the msgSize
//TODO: use the tableOid, and tablePosition //TODO: use the tableOid, and tablePosition
if (fields != null) if (fields != null)
throw new PSQLException("postgresql.con.multres"); throw new PSQLException("postgresql.con.multres", PSQLState.CONNECTION_FAILURE);
int l_msgSize = pgStream.ReceiveIntegerR(4); int l_msgSize = pgStream.ReceiveIntegerR(4);
int size = pgStream.ReceiveIntegerR(2); int size = pgStream.ReceiveIntegerR(2);
fields = new Field[size]; fields = new Field[size];
...@@ -491,7 +494,7 @@ public class QueryExecutor ...@@ -491,7 +494,7 @@ public class QueryExecutor
private void receiveFieldsV2() throws SQLException private void receiveFieldsV2() throws SQLException
{ {
if (fields != null) if (fields != null)
throw new PSQLException("postgresql.con.multres"); throw new PSQLException("postgresql.con.multres", PSQLState.CONNECTION_FAILURE);
int size = pgStream.ReceiveIntegerR(2); int size = pgStream.ReceiveIntegerR(2);
fields = new Field[size]; fields = new Field[size];
......
...@@ -9,6 +9,8 @@ postgresql.con.invalidchar:Invalid character data was found. This is most likel ...@@ -9,6 +9,8 @@ postgresql.con.invalidchar:Invalid character data was found. This is most likel
postgresql.con.closed:Connection is closed. Operation is not permitted. postgresql.con.closed:Connection is closed. Operation is not permitted.
postgresql.con.creobj:Failed to create object for {0} {1} postgresql.con.creobj:Failed to create object for {0} {1}
postgresql.con.failed:The connection attempt failed because {0} postgresql.con.failed:The connection attempt failed because {0}
postgresql.con.failed.bad.encoding:The connection attempt failed trying to get the server encoding
postgresql.con.failed.bad.autocommit:The connection attempt failed trying to get the autocommit status
postgresql.con.fathom:Unable to fathom update count {0} postgresql.con.fathom:Unable to fathom update count {0}
postgresql.con.garbled:Garbled data received. postgresql.con.garbled:Garbled data received.
postgresql.con.ioerror:An IO erro occured while sending to the backend - {0} postgresql.con.ioerror:An IO erro occured while sending to the backend - {0}
...@@ -29,6 +31,11 @@ postgresql.con.isolevel:Transaction isolation level {0} is not supported. ...@@ -29,6 +31,11 @@ postgresql.con.isolevel:Transaction isolation level {0} is not supported.
postgresql.con.tuple:Tuple received before MetaData. postgresql.con.tuple:Tuple received before MetaData.
postgresql.con.type:Unknown Response Type {0} postgresql.con.type:Unknown Response Type {0}
postgresql.con.user:The user property is missing. It is mandatory. postgresql.con.user:The user property is missing. It is mandatory.
postgresql.error.detail:Detail: {0}
postgresql.error.hint:Hint: {0}
postgresql.error.position:Position: {0}
postgresql.error.where:Where: {0}
postgresql.error.location:Location: {0}
postgresql.fp.error:FastPath call returned {0} postgresql.fp.error:FastPath call returned {0}
postgresql.fp.expint:Fastpath call {0} - No result was returned and we expected an integer. postgresql.fp.expint:Fastpath call {0} - No result was returned and we expected an integer.
postgresql.fp.protocol:FastPath protocol error: {0} postgresql.fp.protocol:FastPath protocol error: {0}
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Attic/Fastpath.java,v 1.14 2003/05/29 04:39:51 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Attic/Fastpath.java,v 1.15 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,6 +20,7 @@ import org.postgresql.Driver; ...@@ -20,6 +20,7 @@ import org.postgresql.Driver;
import org.postgresql.core.BaseConnection; import org.postgresql.core.BaseConnection;
import org.postgresql.core.PGStream; import org.postgresql.core.PGStream;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
/* /*
* This class implements the Fastpath api. * This class implements the Fastpath api.
...@@ -100,14 +101,14 @@ public class Fastpath ...@@ -100,14 +101,14 @@ public class Fastpath
} }
catch (IOException ioe) catch (IOException ioe)
{ {
throw new PSQLException("postgresql.fp.send", new Integer(fnid), ioe); throw new PSQLException("postgresql.fp.send", PSQLState.COMMUNICATION_ERROR, new Integer(fnid), ioe);
} }
// Now handle the result // Now handle the result
// Now loop, reading the results // Now loop, reading the results
Object result = null; // our result Object result = null; // our result
StringBuffer errorMessage = null; PSQLException error = null;
int c; int c;
boolean l_endQuery = false; boolean l_endQuery = false;
while (!l_endQuery) while (!l_endQuery)
...@@ -124,11 +125,16 @@ public class Fastpath ...@@ -124,11 +125,16 @@ public class Fastpath
//------------------------------ //------------------------------
// Error message returned // Error message returned
case 'E': case 'E':
if ( errorMessage == null )
errorMessage = new StringBuffer();
int l_elen = stream.ReceiveIntegerR(4); int l_elen = stream.ReceiveIntegerR(4);
errorMessage.append(conn.getEncoding().decode(stream.Receive(l_elen-4))); String totalMessage = conn.getEncoding().decode(stream.Receive(l_elen-4));
PSQLException l_error = PSQLException.parseServerError(totalMessage);
if (error != null) {
error.setNextException(l_error);
} else {
error = l_error;
}
break; break;
//------------------------------ //------------------------------
// Notice from backend // Notice from backend
...@@ -165,7 +171,7 @@ public class Fastpath ...@@ -165,7 +171,7 @@ public class Fastpath
case 'Z': case 'Z':
//TODO: use size better //TODO: use size better
if (stream.ReceiveIntegerR(4) != 5) throw new PSQLException("postgresql.con.setup"); if (stream.ReceiveIntegerR(4) != 5) throw new PSQLException("postgresql.con.setup", PSQLState.CONNECTION_UNABLE_TO_CONNECT);
//TODO: handle transaction status //TODO: handle transaction status
char l_tStatus = (char)stream.ReceiveChar(); char l_tStatus = (char)stream.ReceiveChar();
l_endQuery = true; l_endQuery = true;
...@@ -176,8 +182,8 @@ public class Fastpath ...@@ -176,8 +182,8 @@ public class Fastpath
} }
} }
if ( errorMessage != null ) if ( error != null )
throw new PSQLException("postgresql.fp.error", errorMessage.toString()); throw error;
return result; return result;
} }
...@@ -208,7 +214,8 @@ public class Fastpath ...@@ -208,7 +214,8 @@ public class Fastpath
} }
catch (IOException ioe) catch (IOException ioe)
{ {
throw new PSQLException("postgresql.fp.send", new Integer(fnid), ioe); //Should be sending exception as second arg.
throw new PSQLException("postgresql.fp.send", PSQLState.COMMUNICATION_ERROR, new Integer(fnid), ioe);
} }
// Now handle the result // Now handle the result
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.15 2003/08/24 22:10:09 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.16 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -32,6 +32,7 @@ import org.postgresql.largeobject.*; ...@@ -32,6 +32,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.PGbytea; import org.postgresql.util.PGbytea;
import org.postgresql.util.PGtokenizer; import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
public abstract class AbstractJdbc1ResultSet implements BaseResultSet public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
...@@ -115,7 +116,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -115,7 +116,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
public boolean next() throws SQLException public boolean next() throws SQLException
{ {
if (rows == null) if (rows == null)
throw new PSQLException("postgresql.con.closed"); throw new PSQLException("postgresql.con.closed", PSQLState.CONNECTION_DOES_NOT_EXIST);
if (++current_row >= rows.size()) if (++current_row >= rows.size())
{ {
...@@ -1139,7 +1140,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -1139,7 +1140,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
} }
catch (ParseException e) catch (ParseException e)
{ {
throw new PSQLException("postgresql.res.badtimestamp", new Integer(e.getErrorOffset()), s); throw new PSQLException("postgresql.res.badtimestamp", PSQLState.UNKNOWN_STATE, new Integer(e.getErrorOffset()), s);
} }
} }
} }
......
...@@ -10,6 +10,7 @@ import org.postgresql.largeobject.LargeObjectManager; ...@@ -10,6 +10,7 @@ import org.postgresql.largeobject.LargeObjectManager;
import org.postgresql.util.PGbytea; import org.postgresql.util.PGbytea;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
...@@ -25,7 +26,7 @@ import java.sql.Timestamp; ...@@ -25,7 +26,7 @@ import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import java.util.Vector; import java.util.Vector;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.33 2003/08/26 06:50:39 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.34 2003/09/08 17:30:22 barry Exp $
* This class defines methods of the jdbc1 specification. This class is * This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
...@@ -676,7 +677,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -676,7 +677,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
*/ */
public void cancel() throws SQLException public void cancel() throws SQLException
{ {
throw new PSQLException("postgresql.unimplemented"); throw new PSQLException("postgresql.unimplemented", PSQLState.NOT_IMPLEMENTED);
} }
/* /*
...@@ -1558,7 +1559,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1558,7 +1559,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
} }
else else
{ {
throw new PSQLException("postgresql.prep.type"); throw new PSQLException("postgresql.prep.type", PSQLState.INVALID_PARAMETER_TYPE);
} }
break; break;
case Types.BINARY: case Types.BINARY:
...@@ -1570,7 +1571,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1570,7 +1571,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
setString(parameterIndex, ((PGobject)x).getValue(), PG_TEXT); setString(parameterIndex, ((PGobject)x).getValue(), PG_TEXT);
break; break;
default: default:
throw new PSQLException("postgresql.prep.type"); throw new PSQLException("postgresql.prep.type", PSQLState.INVALID_PARAMETER_TYPE);
} }
} }
...@@ -1954,7 +1955,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1954,7 +1955,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
private void bind(int paramIndex, Object s, String type) throws SQLException private void bind(int paramIndex, Object s, String type) throws SQLException
{ {
if (paramIndex < 1 || paramIndex > m_binds.length) if (paramIndex < 1 || paramIndex > m_binds.length)
throw new PSQLException("postgresql.prep.range"); throw new PSQLException("postgresql.prep.range", PSQLState.PARAMETER_ERROR);
if (paramIndex == 1 && isFunction) // need to registerOut instead if (paramIndex == 1 && isFunction) // need to registerOut instead
throw new PSQLException ("postgresql.call.funcover"); throw new PSQLException ("postgresql.call.funcover");
m_binds[paramIndex - 1] = s; m_binds[paramIndex - 1] = s;
...@@ -2096,7 +2097,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -2096,7 +2097,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
} }
catch (Exception e) catch (Exception e)
{ {
throw new PSQLException("postgresql.format.baddate",s , "yyyy-MM-dd[-tz]"); throw new PSQLException("postgresql.format.baddate", PSQLState.UNKNOWN_STATE, s , "yyyy-MM-dd[-tz]");
} }
timezone = 0; timezone = 0;
if (timezoneLocation>7 && timezoneLocation+3 == s.length()) if (timezoneLocation>7 && timezoneLocation+3 == s.length())
...@@ -2127,7 +2128,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -2127,7 +2128,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
} }
catch (Exception e) catch (Exception e)
{ {
throw new PSQLException("postgresql.format.badtime",s, "HH:mm:ss[-tz]"); throw new PSQLException("postgresql.format.badtime", PSQLState.UNKNOWN_STATE, s, "HH:mm:ss[-tz]");
} }
timezone = 0; timezone = 0;
if (timezoneLocation != -1 && timezoneLocation+3 == s.length()) if (timezoneLocation != -1 && timezoneLocation+3 == s.length())
...@@ -2166,7 +2167,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -2166,7 +2167,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
} }
catch (Exception e) catch (Exception e)
{ {
throw new PSQLException("postgresql.format.badtimestamp", s, "yyyy-MM-dd HH:mm:ss[.xxxxxx][-tz]"); throw new PSQLException("postgresql.format.badtimestamp", PSQLState.UNKNOWN_STATE, s, "yyyy-MM-dd HH:mm:ss[.xxxxxx][-tz]");
} }
timezone = 0; timezone = 0;
if (nanospos != -1) if (nanospos != -1)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.21 2003/08/11 21:33:50 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.22 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -30,6 +30,7 @@ import org.postgresql.core.BaseStatement; ...@@ -30,6 +30,7 @@ import org.postgresql.core.BaseStatement;
import org.postgresql.core.Field; import org.postgresql.core.Field;
import org.postgresql.core.Encoding; import org.postgresql.core.Encoding;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet
...@@ -421,7 +422,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -421,7 +422,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public Ref getRef(int i) throws SQLException public Ref getRef(int i) throws SQLException
{ {
//The backend doesn't yet have SQL3 REF types //The backend doesn't yet have SQL3 REF types
throw new PSQLException("postgresql.psqlnotimp"); throw new PSQLException("postgresql.psqlnotimp", PSQLState.NOT_IMPLEMENTED);
} }
...@@ -513,7 +514,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -513,7 +514,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public void setFetchDirection(int direction) throws SQLException public void setFetchDirection(int direction) throws SQLException
{ {
throw new PSQLException("postgresql.psqlnotimp"); throw new PSQLException("postgresql.psqlnotimp", PSQLState.NOT_IMPLEMENTED);
} }
......
...@@ -8,8 +8,9 @@ import java.util.Vector; ...@@ -8,8 +8,9 @@ import java.util.Vector;
import org.postgresql.Driver; import org.postgresql.Driver;
import org.postgresql.largeobject.*; import org.postgresql.largeobject.*;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.15 2003/06/30 16:38:30 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.16 2003/09/08 17:30:22 barry Exp $
* This class defines methods of the jdbc2 specification. This class extends * This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1 * org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Statement * methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Statement
...@@ -129,7 +130,7 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra ...@@ -129,7 +130,7 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra
public int getFetchDirection() throws SQLException public int getFetchDirection() throws SQLException
{ {
throw new PSQLException("postgresql.psqlnotimp"); throw new PSQLException("postgresql.psqlnotimp", PSQLState.NOT_IMPLEMENTED);
} }
public int getResultSetConcurrency() throws SQLException public int getResultSetConcurrency() throws SQLException
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/MessageTranslator.java,v 1.4 2003/03/07 18:39:46 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/MessageTranslator.java,v 1.5 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -56,6 +56,14 @@ public class MessageTranslator ...@@ -56,6 +56,14 @@ public class MessageTranslator
return translator._translate(id, args); return translator._translate(id, args);
} }
public final static String translate(String id, Object arg)
{
MessageTranslator translator = MessageTranslator.getInstance();
Object[] args = new Object[1];
args[0] = arg;
return translator._translate(id, args);
}
private final String _translate(String id, Object[] args) private final String _translate(String id, Object[] args)
{ {
String message; String message;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PSQLException.java,v 1.12 2003/08/11 21:18:47 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PSQLException.java,v 1.13 2003/09/08 17:30:22 barry Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -16,33 +16,149 @@ package org.postgresql.util; ...@@ -16,33 +16,149 @@ package org.postgresql.util;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Hashtable;
import org.postgresql.Driver; import org.postgresql.Driver;
public class PSQLException extends SQLException public class PSQLException extends SQLException
{ {
private String message; private String message;
private PSQLState state;
/* //-------start new constructors-------
* This provides the same functionality to SQLException
* @param error Error string public PSQLException(String msg, PSQLState state)
*/
public PSQLException(String error)
{ {
super(); this.state = state;
translate(error, null); translate(msg, null);
if (Driver.logDebug)
Driver.debug("Exception: " + this);
}
public PSQLException(String msg, PSQLState state, Object[] argv)
{
this.state = state;
translate(msg, argv);
if (Driver.logDebug)
Driver.debug("Exception: " + this);
}
//Helper version for one arg
public PSQLException(String msg, PSQLState state, Object arg1)
{
this.state = state;
Object[] argv = new Object[1];
argv[0] = arg1;
translate(msg, argv);
if (Driver.logDebug)
Driver.debug("Exception: " + this);
}
//Helper version for two args
public PSQLException(String msg, PSQLState state, Object arg1, Object arg2)
{
this.state = state;
Object[] argv = new Object[2];
argv[0] = arg1;
argv[1] = arg2;
translate(msg, argv);
if (Driver.logDebug) if (Driver.logDebug)
Driver.debug("Exception: " + this); Driver.debug("Exception: " + this);
} }
//-------end new constructors-------
public static PSQLException parseServerError(String p_serverError)
{
if (Driver.logDebug)
Driver.debug("Constructing exception from server message: " + p_serverError);
char[] l_chars = p_serverError.toCharArray();
int l_pos = 0;
int l_length = l_chars.length;
Hashtable l_mesgParts = new Hashtable();
while (l_pos < l_length) {
char l_mesgType = l_chars[l_pos];
if (l_mesgType != '\0') {
l_pos++;
int l_startString = l_pos;
while (l_chars[l_pos] != '\0' && l_pos < l_length) {
l_pos++;
}
String l_mesgPart = new String(l_chars, l_startString, l_pos - l_startString);
l_mesgParts.put(new Character(l_mesgType),l_mesgPart);
}
l_pos++;
}
//Now construct the message from what the server sent
//The general format is:
//SEVERITY: Message \n
// Detail: \n
// Hint: \n
// Position: \n
// Where: \n
// Location: File:Line:Routine \n
// SQLState: \n
//
//Normally only the message and detail is included.
//If INFO level logging is enabled then detail, hint, position and where are
//included. If DEBUG level logging is enabled then all information
//is included.
StringBuffer l_totalMessage = new StringBuffer();
String l_message = (String)l_mesgParts.get(MESSAGE_TYPE_S);
if (l_message != null)
l_totalMessage.append(l_message).append(": ");
l_message = (String)l_mesgParts.get(MESSAGE_TYPE_M);
if (l_message != null)
l_totalMessage.append(l_message).append('\n');
if (Driver.logInfo) {
l_message = (String)l_mesgParts.get(MESSAGE_TYPE_D);
if (l_message != null)
l_totalMessage.append(" ").append(MessageTranslator.translate("postgresql.error.detail", l_message)).append('\n');
l_message = (String)l_mesgParts.get(MESSAGE_TYPE_H);
if (l_message != null)
l_totalMessage.append(" ").append(MessageTranslator.translate("postgresql.error.hint", l_message)).append('\n');
l_message = (String)l_mesgParts.get(MESSAGE_TYPE_P);
if (l_message != null)
l_totalMessage.append(" ").append(MessageTranslator.translate("postgresql.error.position", l_message)).append('\n');
l_message = (String)l_mesgParts.get(MESSAGE_TYPE_W);
if (l_message != null)
l_totalMessage.append(" ").append(MessageTranslator.translate("postgresql.error.where", l_message)).append('\n');
}
if (Driver.logDebug) {
String l_file = (String)l_mesgParts.get(MESSAGE_TYPE_F);
String l_line = (String)l_mesgParts.get(MESSAGE_TYPE_L);
String l_routine = (String)l_mesgParts.get(MESSAGE_TYPE_R);
if (l_file != null || l_line != null || l_routine != null)
l_totalMessage.append(" ").append(MessageTranslator.translate("postgresql.error.location", l_file+":"+l_line+":"+l_routine)).append('\n');
l_message = (String)l_mesgParts.get(MESSAGE_TYPE_C);
if (l_message != null)
l_totalMessage.append(" ").append("ServerSQLState: " + l_message).append('\n');
}
PSQLException l_return = new PSQLException(l_totalMessage.toString(), PSQLState.UNKNOWN_STATE);
l_return.state = new PSQLState((String)l_mesgParts.get(MESSAGE_TYPE_C));
return l_return;
}
private static final Character MESSAGE_TYPE_S = new Character('S');
private static final Character MESSAGE_TYPE_M = new Character('M');
private static final Character MESSAGE_TYPE_D = new Character('D');
private static final Character MESSAGE_TYPE_H = new Character('H');
private static final Character MESSAGE_TYPE_P = new Character('P');
private static final Character MESSAGE_TYPE_W = new Character('W');
private static final Character MESSAGE_TYPE_F = new Character('F');
private static final Character MESSAGE_TYPE_L = new Character('L');
private static final Character MESSAGE_TYPE_R = new Character('R');
private static final Character MESSAGE_TYPE_C = new Character('C');
/* /*
* A more generic entry point. * This provides the same functionality to SQLException
* @param error Error string or standard message id * @param error Error string
* @param args Array of arguments
*/ */
public PSQLException(String error, Object[] args) public PSQLException(String error)
{ {
super(); translate(error, null);
translate(error, args);
if (Driver.logDebug) if (Driver.logDebug)
Driver.debug("Exception: " + this); Driver.debug("Exception: " + this);
} }
...@@ -52,7 +168,6 @@ public class PSQLException extends SQLException ...@@ -52,7 +168,6 @@ public class PSQLException extends SQLException
*/ */
public PSQLException(String error, Object arg) public PSQLException(String error, Object arg)
{ {
super();
Object[] argv = new Object[1]; Object[] argv = new Object[1];
argv[0] = arg; argv[0] = arg;
translate(error, argv); translate(error, argv);
...@@ -60,56 +175,35 @@ public class PSQLException extends SQLException ...@@ -60,56 +175,35 @@ public class PSQLException extends SQLException
Driver.debug("Exception: " + this); Driver.debug("Exception: " + this);
} }
/*
* Helper version for 1 arg. This is used for debug purposes only with
* some unusual Exception's. It allows the originiating Exceptions stack
* trace to be returned.
*/
public PSQLException(String error, Exception ex)
{
super();
Object[] argv = new Object[1];
try private void translate(String error, Object[] args) {
{ //We convert exception objects to Strings that
//contain the full stack trace
if (args != null) {
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof Exception && !(args[i] instanceof PSQLException)) {
Exception ex = (Exception) args[i];
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos); PrintWriter pw = new PrintWriter(baos);
pw.println("Exception: " + ex.toString() + "\nStack Trace:\n"); pw.println("Exception: " + ex.toString() + "\nStack Trace:\n");
ex.printStackTrace(pw); ex.printStackTrace(pw);
pw.println("End of Stack Trace"); pw.println("End of Stack Trace");
pw.flush(); pw.flush();
argv[0] = baos.toString(); args[i] = baos.toString();
pw.close(); pw.close();
baos.close(); baos.close();
} }
catch (Exception ioe) catch (Exception ioe)
{ {
argv[0] = ex.toString() + "\nIO Error on stack trace generation! " + ioe.toString(); args[i] = ex.toString() + "\nIO Error on stack trace generation! " + ioe.toString();
}
} }
translate(error, argv);
if (Driver.logDebug)
Driver.debug("Exception: " + this);
} }
/*
* Helper version for 2 args
*/
public PSQLException(String error, Object arg1, Object arg2)
{
super();
Object[] argv = new Object[2];
argv[0] = arg1;
argv[1] = arg2;
translate(error, argv);
if (Driver.logDebug)
Driver.debug("Exception: " + this);
} }
private void translate(String error, Object[] args)
{
message = MessageTranslator.translate(error, args); message = MessageTranslator.translate(error, args);
} }
/* /*
...@@ -127,4 +221,9 @@ public class PSQLException extends SQLException ...@@ -127,4 +221,9 @@ public class PSQLException extends SQLException
{ {
return message; return message;
} }
public String getSQLState()
{
return state.getState();
}
} }
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