Attempt III

This commit is contained in:
Peter Mount 2000-04-26 05:39:32 +00:00
parent 39116bfbfc
commit 4fc3690238
9 changed files with 1980 additions and 0 deletions

View File

@ -0,0 +1,752 @@
package org.postgresql;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import org.postgresql.Field;
import org.postgresql.fastpath.*;
import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/**
* $Id: Connection.java,v 1.1 2000/04/26 05:39:32 peter Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
*
*/
public abstract class Connection
{
// This is the network stream associated with this connection
public PG_Stream pg_stream;
// This is set by org.postgresql.Statement.setMaxRows()
public int maxrows = 0; // maximum no. of rows; 0 = unlimited
private String PG_HOST;
private int PG_PORT;
private String PG_USER;
private String PG_PASSWORD;
private String PG_DATABASE;
private boolean PG_STATUS;
public boolean CONNECTION_OK = true;
public boolean CONNECTION_BAD = false;
public boolean autoCommit = true;
public boolean readOnly = false;
public Driver this_driver;
private String this_url;
private String cursor = null; // The positioned update cursor name
// These are new for v6.3, they determine the current protocol versions
// supported by this version of the driver. They are defined in
// src/include/libpq/pqcomm.h
protected static final int PG_PROTOCOL_LATEST_MAJOR = 2;
protected static final int PG_PROTOCOL_LATEST_MINOR = 0;
private static final int SM_DATABASE = 64;
private static final int SM_USER = 32;
private static final int SM_OPTIONS = 64;
private static final int SM_UNUSED = 64;
private static final int SM_TTY = 64;
private static final int AUTH_REQ_OK = 0;
private static final int AUTH_REQ_KRB4 = 1;
private static final int AUTH_REQ_KRB5 = 2;
private static final int AUTH_REQ_PASSWORD = 3;
private static final int AUTH_REQ_CRYPT = 4;
// New for 6.3, salt value for crypt authorisation
private String salt;
// This is used by Field to cache oid -> names.
// It's here, because it's shared across this connection only.
// Hence it cannot be static within the Field class, because it would then
// be across all connections, which could be to different backends.
public Hashtable fieldCache = new Hashtable();
// Now handle notices as warnings, so things like "show" now work
public SQLWarning firstWarning = null;
// The PID an cancellation key we get from the backend process
public int pid;
public int ckey;
/**
* This is called by Class.forName() from within org.postgresql.Driver
*/
public Connection()
{
}
/**
* This method actually opens the connection. It is called by Driver.
*
* @param host the hostname of the database back end
* @param port the port number of the postmaster process
* @param info a Properties[] thing of the user and password
* @param database the database to connect to
* @param u the URL of the connection
* @param d the Driver instantation of the connection
* @return a valid connection profile
* @exception SQLException if a database access error occurs
*/
protected void openConnection(String host, int port, Properties info, String database, String url, Driver d) throws SQLException
{
// Throw an exception if the user or password properties are missing
// This occasionally occurs when the client uses the properties version
// of getConnection(), and is a common question on the email lists
if(info.getProperty("user")==null)
throw new PSQLException("postgresql.con.user");
if(info.getProperty("password")==null)
throw new PSQLException("postgresql.con.pass");
this_driver = d;
this_url = new String(url);
PG_DATABASE = new String(database);
PG_PASSWORD = new String(info.getProperty("password"));
PG_USER = new String(info.getProperty("user"));
PG_PORT = port;
PG_HOST = new String(host);
PG_STATUS = CONNECTION_BAD;
// Now make the initial connection
try
{
pg_stream = new PG_Stream(host, port);
} catch (ConnectException cex) {
// Added by Peter Mount <peter@retep.org.uk>
// ConnectException is thrown when the connection cannot be made.
// we trap this an return a more meaningful message for the end user
throw new PSQLException ("postgresql.con.refused");
} catch (IOException e) {
throw new PSQLException ("postgresql.con.failed",e);
}
// Now we need to construct and send a startup packet
try
{
// Ver 6.3 code
pg_stream.SendInteger(4+4+SM_DATABASE+SM_USER+SM_OPTIONS+SM_UNUSED+SM_TTY,4);
pg_stream.SendInteger(PG_PROTOCOL_LATEST_MAJOR,2);
pg_stream.SendInteger(PG_PROTOCOL_LATEST_MINOR,2);
pg_stream.Send(database.getBytes(),SM_DATABASE);
// This last send includes the unused fields
pg_stream.Send(PG_USER.getBytes(),SM_USER+SM_OPTIONS+SM_UNUSED+SM_TTY);
// now flush the startup packets to the backend
pg_stream.flush();
// Now get the response from the backend, either an error message
// or an authentication request
int areq = -1; // must have a value here
do {
int beresp = pg_stream.ReceiveChar();
switch(beresp)
{
case 'E':
// An error occured, so pass the error message to the
// user.
//
// The most common one to be thrown here is:
// "User authentication failed"
//
throw new SQLException(pg_stream.ReceiveString(4096));
case 'R':
// Get the type of request
areq = pg_stream.ReceiveIntegerR(4);
// Get the password salt if there is one
if(areq == AUTH_REQ_CRYPT) {
byte[] rst = new byte[2];
rst[0] = (byte)pg_stream.ReceiveChar();
rst[1] = (byte)pg_stream.ReceiveChar();
salt = new String(rst,0,2);
DriverManager.println("Salt="+salt);
}
// now send the auth packet
switch(areq)
{
case AUTH_REQ_OK:
break;
case AUTH_REQ_KRB4:
DriverManager.println("postgresql: KRB4");
throw new PSQLException("postgresql.con.kerb4");
case AUTH_REQ_KRB5:
DriverManager.println("postgresql: KRB5");
throw new PSQLException("postgresql.con.kerb5");
case AUTH_REQ_PASSWORD:
DriverManager.println("postgresql: PASSWORD");
pg_stream.SendInteger(5+PG_PASSWORD.length(),4);
pg_stream.Send(PG_PASSWORD.getBytes());
pg_stream.SendInteger(0,1);
pg_stream.flush();
break;
case AUTH_REQ_CRYPT:
DriverManager.println("postgresql: CRYPT");
String crypted = UnixCrypt.crypt(salt,PG_PASSWORD);
pg_stream.SendInteger(5+crypted.length(),4);
pg_stream.Send(crypted.getBytes());
pg_stream.SendInteger(0,1);
pg_stream.flush();
break;
default:
throw new PSQLException("postgresql.con.auth",new Integer(areq));
}
break;
default:
throw new PSQLException("postgresql.con.authfail");
}
} while(areq != AUTH_REQ_OK);
} catch (IOException e) {
throw new PSQLException("postgresql.con.failed",e);
}
// As of protocol version 2.0, we should now receive the cancellation key and the pid
int beresp = pg_stream.ReceiveChar();
switch(beresp) {
case 'K':
pid = pg_stream.ReceiveInteger(4);
ckey = pg_stream.ReceiveInteger(4);
break;
case 'E':
case 'N':
throw new SQLException(pg_stream.ReceiveString(4096));
default:
throw new PSQLException("postgresql.con.setup");
}
// Expect ReadyForQuery packet
beresp = pg_stream.ReceiveChar();
switch(beresp) {
case 'Z':
break;
case 'E':
case 'N':
throw new SQLException(pg_stream.ReceiveString(4096));
default:
throw new PSQLException("postgresql.con.setup");
}
// Originally we issued a SHOW DATESTYLE statement to find the databases default
// datestyle. However, this caused some problems with timestamps, so in 6.5, we
// went the way of ODBC, and set the connection to ISO.
//
// This may cause some clients to break when they assume anything other than ISO,
// but then - they should be using the proper methods ;-)
//
//
firstWarning = null;
ExecSQL("set datestyle to 'ISO'");
// Initialise object handling
initObjectTypes();
// Mark the connection as ok, and cleanup
firstWarning = null;
PG_STATUS = CONNECTION_OK;
}
// These methods used to be in the main Connection implementation. As they
// are common to all implementations (JDBC1 or 2), they are placed here.
// This should make it easy to maintain the two specifications.
/**
* This adds a warning to the warning chain.
* @param msg message to add
*/
public void addWarning(String msg)
{
DriverManager.println(msg);
// Add the warning to the chain
if(firstWarning!=null)
firstWarning.setNextWarning(new SQLWarning(msg));
else
firstWarning = new SQLWarning(msg);
// Now check for some specific messages
// This is obsolete in 6.5, but I've left it in here so if we need to use this
// technique again, we'll know where to place it.
//
// This is generated by the SQL "show datestyle"
//if(msg.startsWith("NOTICE:") && msg.indexOf("DateStyle")>0) {
//// 13 is the length off "DateStyle is "
//msg = msg.substring(msg.indexOf("DateStyle is ")+13);
//
//for(int i=0;i<dateStyles.length;i+=2)
//if(msg.startsWith(dateStyles[i]))
//currentDateStyle=i+1; // this is the index of the format
//}
}
/**
* Send a query to the backend. Returns one of the ResultSet
* objects.
*
* <B>Note:</B> there does not seem to be any method currently
* in existance to return the update count.
*
* @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(String sql) throws SQLException
{
// added Oct 7 1998 to give us thread safety.
synchronized(pg_stream) {
Field[] fields = null;
Vector tuples = new Vector();
byte[] buf = new byte[sql.length()];
int fqp = 0;
boolean hfr = false;
String recv_status = null, msg;
int update_count = 1;
SQLException final_error = null;
if (sql.length() > 8192)
throw new PSQLException("postgresql.con.toolong",sql);
try
{
pg_stream.SendChar('Q');
buf = sql.getBytes();
pg_stream.Send(buf);
pg_stream.SendChar(0);
pg_stream.flush();
} catch (IOException e) {
throw new PSQLException("postgresql.con.ioerror",e);
}
while (!hfr || fqp > 0)
{
Object tup=null; // holds rows as they are recieved
int c = pg_stream.ReceiveChar();
switch (c)
{
case 'A': // Asynchronous Notify
pid = pg_stream.ReceiveInteger(4);
msg = pg_stream.ReceiveString(8192);
break;
case 'B': // Binary Data Transfer
if (fields == null)
throw new PSQLException("postgresql.con.tuple");
tup = pg_stream.ReceiveTuple(fields.length, true);
// This implements Statement.setMaxRows()
if(maxrows==0 || tuples.size()<maxrows)
tuples.addElement(tup);
break;
case 'C': // Command Status
recv_status = pg_stream.ReceiveString(8192);
// Now handle the update count correctly.
if(recv_status.startsWith("INSERT") || recv_status.startsWith("UPDATE")) {
try {
update_count = Integer.parseInt(recv_status.substring(1+recv_status.lastIndexOf(' ')));
} catch(NumberFormatException nfe) {
throw new PSQLException("postgresql.con.fathom",recv_status);
}
}
if (fields != null)
hfr = true;
else
{
try
{
pg_stream.SendChar('Q');
pg_stream.SendChar(' ');
pg_stream.SendChar(0);
pg_stream.flush();
} catch (IOException e) {
throw new PSQLException("postgresql.con.ioerror",e);
}
fqp++;
}
break;
case 'D': // Text Data Transfer
if (fields == null)
throw new PSQLException("postgresql.con.tuple");
tup = pg_stream.ReceiveTuple(fields.length, false);
// This implements Statement.setMaxRows()
if(maxrows==0 || tuples.size()<maxrows)
tuples.addElement(tup);
break;
case 'E': // Error Message
msg = pg_stream.ReceiveString(4096);
final_error = new SQLException(msg);
hfr = true;
break;
case 'I': // Empty Query
int t = pg_stream.ReceiveChar();
if (t != 0)
throw new PSQLException("postgresql.con.garbled");
if (fqp > 0)
fqp--;
if (fqp == 0)
hfr = true;
break;
case 'N': // Error Notification
addWarning(pg_stream.ReceiveString(4096));
break;
case 'P': // Portal Name
String pname = pg_stream.ReceiveString(8192);
break;
case 'T': // MetaData Field Description
if (fields != null)
throw new PSQLException("postgresql.con.multres");
fields = ReceiveFields();
break;
case 'Z': // backend ready for query, ignore for now :-)
break;
default:
throw new PSQLException("postgresql.con.type",new Character((char)c));
}
}
if (final_error != null)
throw final_error;
return getResultSet(this, fields, tuples, recv_status, update_count);
}
}
/**
* Receive the field descriptions from the back end
*
* @return an array of the Field object describing the fields
* @exception SQLException if a database error occurs
*/
private Field[] ReceiveFields() throws SQLException
{
int nf = pg_stream.ReceiveIntegerR(2), i;
Field[] fields = new Field[nf];
for (i = 0 ; i < nf ; ++i)
{
String typname = pg_stream.ReceiveString(8192);
int typid = pg_stream.ReceiveIntegerR(4);
int typlen = pg_stream.ReceiveIntegerR(2);
int typmod = pg_stream.ReceiveIntegerR(4);
fields[i] = new Field(this, typname, typid, typlen, typmod);
}
return fields;
}
/**
* In SQL, a result table can be retrieved through a cursor that
* is named. The current row of a result can be updated or deleted
* using a positioned update/delete statement that references the
* cursor name.
*
* We support one cursor per connection.
*
* setCursorName sets the cursor name.
*
* @param cursor the cursor name
* @exception SQLException if a database access error occurs
*/
public void setCursorName(String cursor) throws SQLException
{
this.cursor = cursor;
}
/**
* getCursorName gets the cursor name.
*
* @return the current cursor name
* @exception SQLException if a database access error occurs
*/
public String getCursorName() throws SQLException
{
return cursor;
}
/**
* We are required to bring back certain information by
* the DatabaseMetaData class. These functions do that.
*
* Method getURL() brings back the URL (good job we saved it)
*
* @return the url
* @exception SQLException just in case...
*/
public String getURL() throws SQLException
{
return this_url;
}
/**
* Method getUserName() brings back the User Name (again, we
* saved it)
*
* @return the user name
* @exception SQLException just in case...
*/
public String getUserName() throws SQLException
{
return PG_USER;
}
/**
* This returns the Fastpath API for the current connection.
*
* <p><b>NOTE:</b> This is not part of JDBC, but allows access to
* functions on the org.postgresql backend itself.
*
* <p>It is primarily used by the LargeObject API
*
* <p>The best way to use this is as follows:
*
* <p><pre>
* import org.postgresql.fastpath.*;
* ...
* Fastpath fp = ((org.postgresql.Connection)myconn).getFastpathAPI();
* </pre>
*
* <p>where myconn is an open Connection to org.postgresql.
*
* @return Fastpath object allowing access to functions on the org.postgresql
* backend.
* @exception SQLException by Fastpath when initialising for first time
*/
public Fastpath getFastpathAPI() throws SQLException
{
if(fastpath==null)
fastpath = new Fastpath(this,pg_stream);
return fastpath;
}
// This holds a reference to the Fastpath API if already open
private Fastpath fastpath = null;
/**
* This returns the LargeObject API for the current connection.
*
* <p><b>NOTE:</b> This is not part of JDBC, but allows access to
* functions on the org.postgresql backend itself.
*
* <p>The best way to use this is as follows:
*
* <p><pre>
* import org.postgresql.largeobject.*;
* ...
* LargeObjectManager lo = ((org.postgresql.Connection)myconn).getLargeObjectAPI();
* </pre>
*
* <p>where myconn is an open Connection to org.postgresql.
*
* @return LargeObject object that implements the API
* @exception SQLException by LargeObject when initialising for first time
*/
public LargeObjectManager getLargeObjectAPI() throws SQLException
{
if(largeobject==null)
largeobject = new LargeObjectManager(this);
return largeobject;
}
// This holds a reference to the LargeObject API if already open
private LargeObjectManager largeobject = null;
/**
* This method is used internally to return an object based around
* org.postgresql's more unique data types.
*
* <p>It uses an internal Hashtable to get the handling class. If the
* type is not supported, then an instance of org.postgresql.util.PGobject
* is returned.
*
* You can use the getValue() or setValue() methods to handle the returned
* object. Custom objects can have their own methods.
*
* In 6.4, this is extended to use the org.postgresql.util.Serialize class to
* allow the Serialization of Java Objects into the database without using
* Blobs. Refer to that class for details on how this new feature works.
*
* @return PGobject for this type, and set to value
* @exception SQLException if value is not correct for this type
* @see org.postgresql.util.Serialize
*/
public Object getObject(String type,String value) throws SQLException
{
try {
Object o = objectTypes.get(type);
// If o is null, then the type is unknown, so check to see if type
// is an actual table name. If it does, see if a Class is known that
// can handle it
if(o == null) {
Serialize ser = new Serialize(this,type);
objectTypes.put(type,ser);
return ser.fetch(Integer.parseInt(value));
}
// If o is not null, and it is a String, then its a class name that
// extends PGobject.
//
// This is used to implement the org.postgresql unique types (like lseg,
// point, etc).
if(o instanceof String) {
// 6.3 style extending PG_Object
PGobject obj = null;
obj = (PGobject)(Class.forName((String)o).newInstance());
obj.setType(type);
obj.setValue(value);
return (Object)obj;
} else {
// If it's an object, it should be an instance of our Serialize class
// If so, then call it's fetch method.
if(o instanceof Serialize)
return ((Serialize)o).fetch(Integer.parseInt(value));
}
} catch(SQLException sx) {
// rethrow the exception. Done because we capture any others next
sx.fillInStackTrace();
throw sx;
} catch(Exception ex) {
throw new PSQLException("postgresql.con.creobj",type,ex);
}
// should never be reached
return null;
}
/**
* This stores an object into the database.
* @param o Object to store
* @return OID of the new rectord
* @exception SQLException if value is not correct for this type
* @see org.postgresql.util.Serialize
*/
public int putObject(Object o) throws SQLException
{
try {
String type = o.getClass().getName();
Object x = objectTypes.get(type);
// If x is null, then the type is unknown, so check to see if type
// is an actual table name. If it does, see if a Class is known that
// can handle it
if(x == null) {
Serialize ser = new Serialize(this,type);
objectTypes.put(type,ser);
return ser.store(o);
}
// If it's an object, it should be an instance of our Serialize class
// If so, then call it's fetch method.
if(x instanceof Serialize)
return ((Serialize)x).store(o);
// Thow an exception because the type is unknown
throw new PSQLException("postgresql.con.strobj");
} catch(SQLException sx) {
// rethrow the exception. Done because we capture any others next
sx.fillInStackTrace();
throw sx;
} catch(Exception ex) {
throw new PSQLException("postgresql.con.strobjex",ex);
}
}
/**
* This allows client code to add a handler for one of org.postgresql's
* more unique data types.
*
* <p><b>NOTE:</b> This is not part of JDBC, but an extension.
*
* <p>The best way to use this is as follows:
*
* <p><pre>
* ...
* ((org.postgresql.Connection)myconn).addDataType("mytype","my.class.name");
* ...
* </pre>
*
* <p>where myconn is an open Connection to org.postgresql.
*
* <p>The handling class must extend org.postgresql.util.PGobject
*
* @see org.postgresql.util.PGobject
*/
public void addDataType(String type,String name)
{
objectTypes.put(type,name);
}
// This holds the available types
private Hashtable objectTypes = new Hashtable();
// This array contains the types that are supported as standard.
//
// The first entry is the types name on the database, the second
// the full class name of the handling class.
//
private static final String defaultObjectTypes[][] = {
{"box", "postgresql.geometric.PGbox"},
{"circle", "postgresql.geometric.PGcircle"},
{"line", "postgresql.geometric.PGline"},
{"lseg", "postgresql.geometric.PGlseg"},
{"path", "postgresql.geometric.PGpath"},
{"point", "postgresql.geometric.PGpoint"},
{"polygon", "postgresql.geometric.PGpolygon"},
{"money", "postgresql.util.PGmoney"}
};
// This initialises the objectTypes hashtable
private void initObjectTypes()
{
for(int i=0;i<defaultObjectTypes.length;i++)
objectTypes.put(defaultObjectTypes[i][0],defaultObjectTypes[i][1]);
}
// These are required by other common classes
public abstract java.sql.Statement createStatement() throws SQLException;
/**
* This returns a resultset. It must be overridden, so that the correct
* version (from jdbc1 or jdbc2) are returned.
*/
protected abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn, Field[] fields, Vector tuples, String status, int updateCount) throws SQLException;
public abstract void close() throws SQLException;
/**
* Overides finalize(). If called, it closes the connection.
*
* This was done at the request of Rachel Greenham
* <rachel@enlarion.demon.co.uk> who hit a problem where multiple
* clients didn't close the connection, and once a fortnight enough
* clients were open to kill the org.postgres server.
*/
public void finalize() throws Throwable
{
close();
}
/**
* This is an attempt to implement SQL Escape clauses
*/
public String EscapeSQL(String sql) {
return sql;
}
}

View File

@ -0,0 +1,371 @@
package org.postgresql;
import java.sql.*;
import java.util.*;
import org.postgresql.util.PSQLException;
/**
* The Java SQL framework allows for multiple database drivers. Each
* driver should supply a class that implements the Driver interface
*
* <p>The DriverManager will try to load as many drivers as it can find and
* then for any given connection request, it will ask each driver in turn
* to try to connect to the target URL.
*
* <p>It is strongly recommended that each Driver class should be small and
* standalone so that the Driver class can be loaded and queried without
* bringing in vast quantities of supporting code.
*
* <p>When a Driver class is loaded, it should create an instance of itself
* and register it with the DriverManager. This means that a user can load
* and register a driver by doing Class.forName("foo.bah.Driver")
*
* @see org.postgresql.Connection
* @see java.sql.Driver
*/
public class Driver implements java.sql.Driver
{
// These should be in sync with the backend that the driver was
// distributed with
static final int MAJORVERSION = 7;
static final int MINORVERSION = 0;
static
{
try {
// moved the registerDriver from the constructor to here
// because some clients call the driver themselves (I know, as
// my early jdbc work did - and that was based on other examples).
// Placing it here, means that the driver is registered once only.
java.sql.DriverManager.registerDriver(new Driver());
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* Construct a new driver and register it with DriverManager
*
* @exception SQLException for who knows what!
*/
public Driver() throws SQLException
{
// Set the connectClass variable so that future calls will handle the correct
// base class
//if(System.getProperty("java.version").startsWith("1.1")) {
//connectClass = "postgresql.jdbc1.Connection";
//} else {
//connectClass = "postgresql.jdbc2.Connection";
//}
// Ok, when the above code was introduced in 6.5 it's intention was to allow
// the driver to automatically detect which version of JDBC was being used
// and to detect the version of the JVM accordingly.
//
// It did this by using the java.version parameter.
//
// However, it was quickly discovered that not all JVM's returned an easily
// parseable version number (ie "1.2") and some don't return a value at all.
// The latter came from a discussion on the advanced java list.
//
// So, to solve this, I've moved the decision out of the driver, and it's now
// a compile time parameter.
//
// For this to work, the Makefile creates a pseudo class which contains the class
// name that will actually make the connection.
}
/**
* Try to make a database connection to the given URL. The driver
* should return "null" if it realizes it is the wrong kind of
* driver to connect to the given URL. This will be common, as
* when the JDBC driverManager is asked to connect to a given URL,
* it passes the URL to each loaded driver in turn.
*
* <p>The driver should raise an SQLException if it is the right driver
* to connect to the given URL, but has trouble connecting to the
* database.
*
* <p>The java.util.Properties argument can be used to pass arbitrary
* string tag/value pairs as connection arguments. Normally, at least
* "user" and "password" properties should be included in the
* properties.
*
* Our protocol takes the forms:
* <PRE>
* jdbc:org.postgresql://host:port/database?param1=val1&...
* </PRE>
*
* @param url the URL of the database to connect to
* @param info a list of arbitrary tag/value pairs as connection
* arguments
* @return a connection to the URL or null if it isnt us
* @exception SQLException if a database access error occurs
* @see java.sql.Driver#connect
*/
public java.sql.Connection connect(String url, Properties info) throws SQLException
{
if((props = parseURL(url,info))==null)
return null;
DriverManager.println("Using "+DriverClass.connectClass);
try {
org.postgresql.Connection con = (org.postgresql.Connection)(Class.forName(DriverClass.connectClass).newInstance());
con.openConnection (host(), port(), props, database(), url, this);
return (java.sql.Connection)con;
} catch(ClassNotFoundException ex) {
throw new PSQLException("postgresql.jvm.version",ex);
} catch(PSQLException ex1) {
// re-throw the exception, otherwise it will be caught next, and a
// org.postgresql.unusual error will be returned instead.
throw ex1;
} catch(Exception ex2) {
throw new PSQLException("postgresql.unusual",ex2);
}
}
/**
* Returns true if the driver thinks it can open a connection to the
* given URL. Typically, drivers will return true if they understand
* the subprotocol specified in the URL and false if they don't. Our
* protocols start with jdbc:org.postgresql:
*
* @see java.sql.Driver#acceptsURL
* @param url the URL of the driver
* @return true if this driver accepts the given URL
* @exception SQLException if a database-access error occurs
* (Dont know why it would *shrug*)
*/
public boolean acceptsURL(String url) throws SQLException
{
if(parseURL(url,null)==null)
return false;
return true;
}
/**
* The getPropertyInfo method is intended to allow a generic GUI
* tool to discover what properties it should prompt a human for
* in order to get enough information to connect to a database.
*
* <p>Note that depending on the values the human has supplied so
* far, additional values may become necessary, so it may be necessary
* to iterate through several calls to getPropertyInfo
*
* @param url the Url of the database to connect to
* @param info a proposed list of tag/value pairs that will be sent on
* connect open.
* @return An array of DriverPropertyInfo objects describing
* possible properties. This array may be an empty array if
* no properties are required
* @exception SQLException if a database-access error occurs
* @see java.sql.Driver#getPropertyInfo
*/
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
{
Properties p = parseURL(url,info);
// naughty, but its best for speed. If anyone adds a property here, then
// this _MUST_ be increased to accomodate them.
DriverPropertyInfo d,dpi[] = new DriverPropertyInfo[0];
//int i=0;
//dpi[i++] = d = new DriverPropertyInfo("auth",p.getProperty("auth","default"));
//d.description = "determines if password authentication is used";
//d.choices = new String[4];
//d.choices[0]="default"; // Get value from org.postgresql.auth property, defaults to trust
//d.choices[1]="trust"; // No password authentication
//d.choices[2]="password"; // Password authentication
//d.choices[3]="ident"; // Ident (RFC 1413) protocol
return dpi;
}
/**
* Gets the drivers major version number
*
* @return the drivers major version number
*/
public int getMajorVersion()
{
return MAJORVERSION;
}
/**
* Get the drivers minor version number
*
* @return the drivers minor version number
*/
public int getMinorVersion()
{
return MINORVERSION;
}
/**
* Report whether the driver is a genuine JDBC compliant driver. A
* driver may only report "true" here if it passes the JDBC compliance
* tests, otherwise it is required to return false. JDBC compliance
* requires full support for the JDBC API and full support for SQL 92
* Entry Level.
*
* <p>For PostgreSQL, this is not yet possible, as we are not SQL92
* compliant (yet).
*/
public boolean jdbcCompliant()
{
return false;
}
private Properties props;
static private String[] protocols = { "jdbc","postgresql" };
/**
* Constructs a new DriverURL, splitting the specified URL into its
* component parts
* @param url JDBC URL to parse
* @param defaults Default properties
* @return Properties with elements added from the url
* @exception SQLException
*/
Properties parseURL(String url,Properties defaults) throws SQLException
{
int state = -1;
Properties urlProps = new Properties(defaults);
String key = new String();
String value = new String();
StringTokenizer st = new StringTokenizer(url, ":/;=&?", true);
for (int count = 0; (st.hasMoreTokens()); count++) {
String token = st.nextToken();
// PM June 29 1997
// Added this, to help me understand how this works.
// Unless you want each token to be processed, leave this commented out
// but don't delete it.
//DriverManager.println("wellFormedURL: state="+state+" count="+count+" token='"+token+"'");
// PM Aug 2 1997 - Modified to allow multiple backends
if (count <= 3) {
if ((count % 2) == 1 && token.equals(":"))
;
else if((count % 2) == 0) {
boolean found=(count==0)?true:false;
for(int tmp=0;tmp<protocols.length;tmp++) {
if(token.equals(protocols[tmp])) {
// PM June 29 1997 Added this property to enable the driver
// to handle multiple backend protocols.
if(count == 2 && tmp > 0) {
urlProps.put("Protocol",token);
found=true;
}
}
}
if(found == false)
return null;
} else return null;
}
else if (count > 3) {
if (count == 4 && token.equals("/")) state = 0;
else if (count == 4) {
urlProps.put("PGDBNAME", token);
state = -2;
}
else if (count == 5 && state == 0 && token.equals("/"))
state = 1;
else if (count == 5 && state == 0)
return null;
else if (count == 6 && state == 1)
urlProps.put("PGHOST", token);
else if (count == 7 && token.equals(":")) state = 2;
else if (count == 8 && state == 2) {
try {
Integer portNumber = Integer.decode(token);
urlProps.put("PGPORT", portNumber.toString());
} catch (Exception e) {
return null;
}
}
else if ((count == 7 || count == 9) &&
(state == 1 || state == 2) && token.equals("/"))
state = -1;
else if (state == -1) {
urlProps.put("PGDBNAME", token);
state = -2;
}
else if (state <= -2 && (count % 2) == 1) {
// PM Aug 2 1997 - added tests for ? and &
if (token.equals(";") || token.equals("?") || token.equals("&") ) state = -3;
else if (token.equals("=")) state = -5;
}
else if (state <= -2 && (count % 2) == 0) {
if (state == -3) key = token;
else if (state == -5) {
value = token;
//DriverManager.println("put("+key+","+value+")");
urlProps.put(key, value);
state = -2;
}
}
}
}
// PM June 29 1997
// This now outputs the properties only if we are logging
// PM Sep 13 1999 Commented out, as it throws a Deprecation warning
// when compiled under JDK1.2.
//if(DriverManager.getLogStream() != null)
// urlProps.list(DriverManager.getLogStream());
return urlProps;
}
/**
* @return the hostname portion of the URL
*/
public String host()
{
return props.getProperty("PGHOST","localhost");
}
/**
* @return the port number portion of the URL or -1 if no port was specified
*/
public int port()
{
return Integer.parseInt(props.getProperty("PGPORT","5432"));
}
/**
* @return the database name of the URL
*/
public String database()
{
return props.getProperty("PGDBNAME");
}
/**
* @return the value of any property specified in the URL or properties
* passed to connect(), or null if not found.
*/
public String property(String name)
{
return props.getProperty(name);
}
/**
* This method was added in v6.5, and simply throws an SQLException
* for an unimplemented method. I decided to do it this way while
* implementing the JDBC2 extensions to JDBC, as it should help keep the
* overall driver size down.
*/
public static SQLException notImplemented()
{
return new PSQLException("postgresql.unimplemented");
}
}

View File

@ -0,0 +1,4 @@
package org.postgresql;
public class DriverClass {
public static String connectClass="org.postgresql.jdbc2.Connection";
}

View File

@ -0,0 +1,169 @@
package org.postgresql;
import java.lang.*;
import java.sql.*;
import java.util.*;
import org.postgresql.*;
import org.postgresql.util.*;
/**
* org.postgresql.Field is a class used to describe fields in a PostgreSQL
* ResultSet
*/
public class Field
{
public int length; // Internal Length of this field
public int oid; // OID of the type
public int mod; // type modifier of this field
public String name; // Name of this field
protected Connection conn; // Connection Instantation
public int sql_type = -1; // The entry in java.sql.Types for this field
public String type_name = null;// The sql type name
/**
* Construct a field based on the information fed to it.
*
* @param conn the connection this field came from
* @param name the name of the field
* @param oid the OID of the field
* @param len the length of the field
*/
public Field(Connection conn, String name, int oid, int length,int mod)
{
this.conn = conn;
this.name = name;
this.oid = oid;
this.length = length;
this.mod = mod;
}
/**
* Constructor without mod parameter.
*
* @param conn the connection this field came from
* @param name the name of the field
* @param oid the OID of the field
* @param len the length of the field
*/
public Field(Connection conn, String name, int oid, int length)
{
this(conn,name,oid,length,0);
}
/**
* @return the oid of this Field's data type
*/
public int getOID()
{
return oid;
}
/**
* the ResultSet and ResultMetaData both need to handle the SQL
* type, which is gained from another query. Note that we cannot
* use getObject() in this, since getObject uses getSQLType().
*
* @return the entry in Types that refers to this field
* @exception SQLException if a database access error occurs
*/
public int getSQLType() throws SQLException
{
if(sql_type == -1) {
type_name = (String)conn.fieldCache.get(new Integer(oid));
// it's not in the cache, so perform a query, and add the result to
// the cache
if(type_name==null) {
ResultSet result = (org.postgresql.ResultSet)conn.ExecSQL("select typname from pg_type where oid = " + oid);
if (result.getColumnCount() != 1 || result.getTupleCount() != 1)
throw new PSQLException("postgresql.unexpected");
result.next();
type_name = result.getString(1);
conn.fieldCache.put(new Integer(oid),type_name);
result.close();
}
sql_type = getSQLType(type_name);
}
return sql_type;
}
/**
* This returns the SQL type. It is called by the Field and DatabaseMetaData classes
* @param type_name PostgreSQL type name
* @return java.sql.Types value for oid
*/
public static int getSQLType(String type_name)
{
int sql_type = Types.OTHER; // default value
for(int i=0;i<types.length;i++)
if(type_name.equals(types[i]))
sql_type=typei[i];
return sql_type;
}
/**
* This table holds the org.postgresql names for the types supported.
* Any types that map to Types.OTHER (eg POINT) don't go into this table.
* They default automatically to Types.OTHER
*
* Note: This must be in the same order as below.
*
* Tip: keep these grouped together by the Types. value
*/
private static final String types[] = {
"int2",
"int4","oid",
"int8",
"cash","money",
"numeric",
"float4",
"float8",
"bpchar","char","char2","char4","char8","char16",
"varchar","text","name","filename",
"bool",
"date",
"time",
"abstime","timestamp"
};
/**
* This table holds the JDBC type for each entry above.
*
* Note: This must be in the same order as above
*
* Tip: keep these grouped together by the Types. value
*/
private static final int typei[] = {
Types.SMALLINT,
Types.INTEGER,Types.INTEGER,
Types.BIGINT,
Types.DECIMAL,Types.DECIMAL,
Types.NUMERIC,
Types.REAL,
Types.DOUBLE,
Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,
Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
Types.BIT,
Types.DATE,
Types.TIME,
Types.TIMESTAMP,Types.TIMESTAMP
};
/**
* We also need to get the type name as returned by the back end.
* This is held in type_name AFTER a call to getSQLType. Since
* we get this information within getSQLType (if it isn't already
* done), we can just call getSQLType and throw away the result.
*
* @return the String representation of the type of this field
* @exception SQLException if a database access error occurs
*/
public String getTypeName() throws SQLException
{
int sql = getSQLType();
return type_name;
}
}

View File

@ -0,0 +1,384 @@
package org.postgresql;
import java.io.*;
import java.lang.*;
import java.net.*;
import java.util.*;
import java.sql.*;
import org.postgresql.*;
import org.postgresql.util.*;
/**
* @version 1.0 15-APR-1997
*
* This class is used by Connection & PGlobj for communicating with the
* backend.
*
* @see java.sql.Connection
*/
// This class handles all the Streamed I/O for a org.postgresql connection
public class PG_Stream
{
private Socket connection;
private InputStream pg_input;
private BufferedOutputStream pg_output;
/**
* Constructor: Connect to the PostgreSQL back end and return
* a stream connection.
*
* @param host the hostname to connect to
* @param port the port number that the postmaster is sitting on
* @exception IOException if an IOException occurs below it.
*/
public PG_Stream(String host, int port) throws IOException
{
connection = new Socket(host, port);
// Submitted by Jason Venner <jason@idiom.com> adds a 10x speed
// improvement on FreeBSD machines (caused by a bug in their TCP Stack)
connection.setTcpNoDelay(true);
// Buffer sizes submitted by Sverre H Huseby <sverrehu@online.no>
pg_input = new BufferedInputStream(connection.getInputStream(), 8192);
pg_output = new BufferedOutputStream(connection.getOutputStream(), 8192);
}
/**
* Sends a single character to the back end
*
* @param val the character to be sent
* @exception IOException if an I/O error occurs
*/
public void SendChar(int val) throws IOException
{
// Original code
//byte b[] = new byte[1];
//b[0] = (byte)val;
//pg_output.write(b);
// Optimised version by Sverre H. Huseby Aug 22 1999 Applied Sep 13 1999
pg_output.write((byte)val);
}
/**
* Sends an integer to the back end
*
* @param val the integer to be sent
* @param siz the length of the integer in bytes (size of structure)
* @exception IOException if an I/O error occurs
*/
public void SendInteger(int val, int siz) throws IOException
{
byte[] buf = new byte[siz];
while (siz-- > 0)
{
buf[siz] = (byte)(val & 0xff);
val >>= 8;
}
Send(buf);
}
/**
* Sends an integer to the back end in reverse order.
*
* This is required when the backend uses the routines in the
* src/backend/libpq/pqcomprim.c module.
*
* As time goes by, this should become obsolete.
*
* @param val the integer to be sent
* @param siz the length of the integer in bytes (size of structure)
* @exception IOException if an I/O error occurs
*/
public void SendIntegerReverse(int val, int siz) throws IOException
{
byte[] buf = new byte[siz];
int p=0;
while (siz-- > 0)
{
buf[p++] = (byte)(val & 0xff);
val >>= 8;
}
Send(buf);
}
/**
* Send an array of bytes to the backend
*
* @param buf The array of bytes to be sent
* @exception IOException if an I/O error occurs
*/
public void Send(byte buf[]) throws IOException
{
pg_output.write(buf);
}
/**
* Send an exact array of bytes to the backend - if the length
* has not been reached, send nulls until it has.
*
* @param buf the array of bytes to be sent
* @param siz the number of bytes to be sent
* @exception IOException if an I/O error occurs
*/
public void Send(byte buf[], int siz) throws IOException
{
Send(buf,0,siz);
}
/**
* Send an exact array of bytes to the backend - if the length
* has not been reached, send nulls until it has.
*
* @param buf the array of bytes to be sent
* @param off offset in the array to start sending from
* @param siz the number of bytes to be sent
* @exception IOException if an I/O error occurs
*/
public void Send(byte buf[], int off, int siz) throws IOException
{
int i;
pg_output.write(buf, off, ((buf.length-off) < siz ? (buf.length-off) : siz));
if((buf.length-off) < siz)
{
for (i = buf.length-off ; i < siz ; ++i)
{
pg_output.write(0);
}
}
}
/**
* Sends a packet, prefixed with the packet's length
* @param buf buffer to send
* @exception SQLException if an I/O Error returns
*/
public void SendPacket(byte[] buf) throws IOException
{
SendInteger(buf.length+4,4);
Send(buf);
}
/**
* Receives a single character from the backend
*
* @return the character received
* @exception SQLException if an I/O Error returns
*/
public int ReceiveChar() throws SQLException
{
int c = 0;
try
{
c = pg_input.read();
if (c < 0) throw new PSQLException("postgresql.stream.eof");
} catch (IOException e) {
throw new PSQLException("postgresql.stream.ioerror",e);
}
return c;
}
/**
* Receives an integer from the backend
*
* @param siz length of the integer in bytes
* @return the integer received from the backend
* @exception SQLException if an I/O error occurs
*/
public int ReceiveInteger(int siz) throws SQLException
{
int n = 0;
try
{
for (int i = 0 ; i < siz ; i++)
{
int b = pg_input.read();
if (b < 0)
throw new PSQLException("postgresql.stream.eof");
n = n | (b << (8 * i)) ;
}
} catch (IOException e) {
throw new PSQLException("postgresql.stream.ioerror",e);
}
return n;
}
/**
* Receives an integer from the backend
*
* @param siz length of the integer in bytes
* @return the integer received from the backend
* @exception SQLException if an I/O error occurs
*/
public int ReceiveIntegerR(int siz) throws SQLException
{
int n = 0;
try
{
for (int i = 0 ; i < siz ; i++)
{
int b = pg_input.read();
if (b < 0)
throw new PSQLException("postgresql.stream.eof");
n = b | (n << 8);
}
} catch (IOException e) {
throw new PSQLException("postgresql.stream.ioerror",e);
}
return n;
}
/**
* Receives a null-terminated string from the backend. Maximum of
* maxsiz bytes - if we don't see a null, then we assume something
* has gone wrong.
*
* @param maxsiz maximum length of string
* @return string from back end
* @exception SQLException if an I/O error occurs
*/
public String ReceiveString(int maxsiz) throws SQLException
{
byte[] rst = new byte[maxsiz];
int s = 0;
try
{
while (s < maxsiz)
{
int c = pg_input.read();
if (c < 0)
throw new PSQLException("postgresql.stream.eof");
else if (c == 0)
break;
else
rst[s++] = (byte)c;
}
if (s >= maxsiz)
throw new PSQLException("postgresql.stream.toomuch");
} catch (IOException e) {
throw new PSQLException("postgresql.stream.ioerror",e);
}
String v = new String(rst, 0, s);
return v;
}
/**
* Read a tuple from the back end. A tuple is a two dimensional
* array of bytes
*
* @param nf the number of fields expected
* @param bin true if the tuple is a binary tuple
* @return null if the current response has no more tuples, otherwise
* an array of strings
* @exception SQLException if a data I/O error occurs
*/
public byte[][] ReceiveTuple(int nf, boolean bin) throws SQLException
{
int i, bim = (nf + 7)/8;
byte[] bitmask = Receive(bim);
byte[][] answer = new byte[nf][0];
int whichbit = 0x80;
int whichbyte = 0;
for (i = 0 ; i < nf ; ++i)
{
boolean isNull = ((bitmask[whichbyte] & whichbit) == 0);
whichbit >>= 1;
if (whichbit == 0)
{
++whichbyte;
whichbit = 0x80;
}
if (isNull)
answer[i] = null;
else
{
int len = ReceiveIntegerR(4);
if (!bin)
len -= 4;
if (len < 0)
len = 0;
answer[i] = Receive(len);
}
}
return answer;
}
/**
* Reads in a given number of bytes from the backend
*
* @param siz number of bytes to read
* @return array of bytes received
* @exception SQLException if a data I/O error occurs
*/
private byte[] Receive(int siz) throws SQLException
{
byte[] answer = new byte[siz];
Receive(answer,0,siz);
return answer;
}
/**
* Reads in a given number of bytes from the backend
*
* @param buf buffer to store result
* @param off offset in buffer
* @param siz number of bytes to read
* @exception SQLException if a data I/O error occurs
*/
public void Receive(byte[] b,int off,int siz) throws SQLException
{
int s = 0;
try
{
while (s < siz)
{
int w = pg_input.read(b, off+s, siz - s);
if (w < 0)
throw new PSQLException("postgresql.stream.eof");
s += w;
}
} catch (IOException e) {
throw new PSQLException("postgresql.stream.ioerror",e);
}
}
/**
* This flushes any pending output to the backend. It is used primarily
* by the Fastpath code.
* @exception SQLException if an I/O error occurs
*/
public void flush() throws SQLException
{
try {
pg_output.flush();
} catch (IOException e) {
throw new PSQLException("postgresql.stream.flush",e);
}
}
/**
* Closes the connection
*
* @exception IOException if a IO Error occurs
*/
public void close() throws IOException
{
pg_output.write("X\0".getBytes());
pg_output.flush();
pg_output.close();
pg_input.close();
connection.close();
}
}

View File

@ -0,0 +1,158 @@
package org.postgresql;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/**
* This class implements the common internal methods used by both JDBC 1 and
* JDBC 2 specifications.
*/
public abstract class ResultSet
{
protected Vector rows; // The results
protected Field fields[]; // The field descriptions
protected String status; // Status of the result
protected int updateCount; // How many rows did we get back?
protected int current_row; // Our pointer to where we are at
protected byte[][] this_row; // the current row result
protected Connection connection; // the connection which we returned from
protected SQLWarning warnings = null; // The warning chain
protected boolean wasNullFlag = false; // the flag for wasNull()
// We can chain multiple resultSets together - this points to
// next resultSet in the chain.
protected ResultSet next = null;
/**
* Create a new ResultSet - Note that we create ResultSets to
* represent the results of everything.
*
* @param fields an array of Field objects (basically, the
* ResultSet MetaData)
* @param tuples Vector of the actual data
* @param status the status string returned from the back end
* @param updateCount the number of rows affected by the operation
* @param cursor the positioned update/delete cursor name
*/
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
{
this.connection = conn;
this.fields = fields;
this.rows = tuples;
this.status = status;
this.updateCount = updateCount;
this.this_row = null;
this.current_row = -1;
}
/**
* We at times need to know if the resultSet we are working
* with is the result of an UPDATE, DELETE or INSERT (in which
* case, we only have a row count), or of a SELECT operation
* (in which case, we have multiple fields) - this routine
* tells us.
*
* @return true if we have tuples available
*/
public boolean reallyResultSet()
{
return (fields != null);
}
/**
* Since ResultSets can be chained, we need some method of
* finding the next one in the chain. The method getNext()
* returns the next one in the chain.
*
* @return the next ResultSet, or null if there are none
*/
public java.sql.ResultSet getNext()
{
return (java.sql.ResultSet)next;
}
/**
* This following method allows us to add a ResultSet object
* to the end of the current chain.
*
* @param r the resultset to add to the end of the chain.
*/
public void append(ResultSet r)
{
if (next == null)
next = r;
else
next.append(r);
}
/**
* If we are just a place holder for results, we still need
* to get an updateCount. This method returns it.
*
* @return the updateCount
*/
public int getResultCount()
{
return updateCount;
}
/**
* We also need to provide a couple of auxiliary functions for
* the implementation of the ResultMetaData functions. In
* particular, we need to know the number of rows and the
* number of columns. Rows are also known as Tuples
*
* @return the number of rows
*/
public int getTupleCount()
{
return rows.size();
}
/**
* getColumnCount returns the number of columns
*
* @return the number of columns
*/
public int getColumnCount()
{
return fields.length;
}
/**
* Returns the status message from the backend.<p>
* It is used internally by the driver.
*
* @return the status string from the backend
*/
public String getStatusString()
{
return status;
}
/**
* returns the OID of a field.<p>
* It is used internally by the driver.
*
* @param field field id
* @return the oid of that field's type
*/
public int getColumnOID(int field)
{
return fields[field-1].getOID();
}
/**
* This is part of the JDBC API, but is required by org.postgresql.Field
*/
public abstract void close() throws SQLException;
public abstract boolean next() throws SQLException;
public abstract String getString(int i) throws SQLException;
}

View File

@ -0,0 +1,69 @@
# This is the default errors
postgresql.con.auth:The authentication type {0} is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or Subnet, and that it is using an authentication scheme supported by the driver.
postgresql.con.authfail:An error occured while getting the authentication request.
postgresql.con.call:Callable Statements are not supported at this time.
postgresql.con.creobj:Failed to create object for {0} {1}
postgresql.con.failed:The connection attempt failed because {0}
postgresql.con.fathom:Unable to fathom update count {0}
postgresql.con.garbled:Garbled data received.
postgresql.con.ioerror:An IO erro occured while sending to the backend - {0}
postgresql.con.kerb4:Kerberos 4 authentication is not supported by this driver.
postgresql.con.kerb5:Kerberos 5 authentication is not supported by this driver.
postgresql.con.multres:Cannot handle multiple result groups.
postgresql.con.pass:The password property is missing. It is mandatory.
postgresql.con.refused:Connection refused. Check that the hostname and port is correct, and that the postmaster is running with the -i flag, which enables TCP/IP networking.
postgresql.con.setup:Protocol error. Session setup failed.
postgresql.con.strobj:The object could not be stored. Check that any tables required have already been created in the database.
postgresql.con.strobjex:Failed to store object - {0}
postgresql.con.toolong:The SQL Statement is too long - {0}
postgresql.con.isolevel:Transaction isolation level {0} is not supported.
postgresql.con.tuple:Tuple received before MetaData.
postgresql.con.type:Unknown Response Type {0}
postgresql.con.user:The user property is missing. It is mandatory.
postgresql.fp.error:FastPath call returned {0}
postgresql.fp.expint:Fastpath call {0} - No result was returned and we expected an integer.
postgresql.fp.protocol:FastPath protocol error: {0}
postgresql.fp.send:Failed to send fastpath call {0} {1}
postgresql.fp.unknown:The fastpath function {0} is unknown.
postgresql.geo.box:Conversion of box failed - {0}
postgresql.geo.circle:Conversion of circle failed - {0}
postgresql.geo.line:Conversion of line failed - {0}
postgresql.geo.lseg:Conversion of lseg failed - {0}
postgresql.geo.path:Cannot tell if path is open or closed.
postgresql.geo.point:Conversion of point failed - {0}
postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding. If that fails, try forcing the version supplying it to the command line using the argument -Djava.version=1.1 or -Djava.version=1.2\nException thrown was {0}
postgresql.lo.init:failed to initialise LargeObject API
postgresql.money:conversion of money failed - {0}.
postgresql.prep.is:InputStream as parameter not supported
postgresql.prep.param:No value specified for parameter {0}.
postgresql.prep.range:Parameter index out of range.
postgresql.prep.type:Unknown Types value.
postgresql.res.badbigdec:Bad BigDecimal {0}
postgresql.res.badbyte:Bad Byte {0}
postgresql.res.baddate:Bad Date Format at {0} in {1}
postgresql.res.baddouble:Bad Double {0}
postgresql.res.badfloat:Bad Float {0}
postgresql.res.badint:Bad Integer {0}
postgresql.res.badlong:Bad Long {0}
postgresql.res.badshort:Bad Short {0}
postgresql.res.badtime:Bad Time {0}
postgresql.res.badtimestamp:Bad Timestamp Format at {0} in {1}
postgresql.res.colname:The column name {0} not found.
postgresql.res.colrange:The column index is out of range.
postgresql.serial.interface:You cannot serialize an interface.
postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {0} is {1} characters.
postgresql.serial.noclass:No class found for {0}.
postgresql.serial.table:The table for {0} is not in the database. Contact the DBA, as the database is in an inconsistent state.
postgresql.serial.underscore:Class names may not have _ in them. You supplied {0}.
postgresql.stat.batch.empty:The batch is empty. There is nothing to execute.
postgresql.stat.batch.error:Batch entry {0} {1} was aborted.
postgresql.stat.maxfieldsize:An attempt to setMaxFieldSize() failed - compile time default in force.
postgresql.stat.noresult:No results were returned by the query.
postgresql.stat.result:A result was returned by the statement, when none was expected.
postgresql.stream.eof:The backend has broken the connection. Possibly the action you have attempted has caused it to close.
postgresql.stream.flush:An I/O error has occured while flushing the output - {0}
postgresql.stream.ioerror:An I/O error occured while reading from backend - {0}
postgresql.stream.toomuch:Too much data was received.
postgresql.unusual:Something unusual has occured to cause the driver to fail. Please report this exception: {0}
postgresql.unimplemented:This method is not yet implemented.
postgresql.unexpected:An unexpected result was returned by a query.

View File

@ -0,0 +1,5 @@
# This is the french version of some errors. Errors not in this file
# are handled by the parent errors.properties file.
postgresql.jvm.version:Le fichier de postgresql.jar ne contient pas les classes correctes de JDBC pour ce JVM. Try que rebuilding.\nException jet<65>ées <20>était {0}
postgresql.unusual:Quelque chose de peu commun s'est produit pour faire <20>échouer le gestionnaire. Veuillez enregistrer cette exception: {0}
postgresql.unimplemented:Cette m<>éthode n'est pas encore appliqu<71>ée.

View File

@ -0,0 +1,68 @@
# This is the default errors
# Dutch translation by Arnout Kuiper (ajkuiper@wxs.nl)
postgresql.con.auth:Het authenticatie type {0} wordt niet ondersteund. Controleer dat het IP adres of subnet van de client is geconfigureerd in de pg_hba.conf file, en dat het een authenticatie protocol gebruikt dat door de driver ondersteund wordt.
postgresql.con.authfail:Een fout trad op tijdens het ophalen van het authenticatie verzoek.
postgresql.con.call:Callable Statements worden op dit moment niet ondersteund.
postgresql.con.creobj:Kon geen object aanmaken voor {0} {1}
postgresql.con.failed:De poging om verbinding the maken faalde omdat {0}
postgresql.con.fathom:Niet in staat om the update telling te peilen {0}
postgresql.con.garbled:Verminkte data ontvangen.
postgresql.con.ioerror:Een I/O fout trad op tijdens het zenden naar de achterkant - {0}
postgresql.con.kerb4:Kerberos 4 authenticatie wordt niet ondersteund door deze driver.
postgresql.con.kerb5:Kerberos 5 authenticatie wordt niet ondersteund door deze driver.
postgresql.con.multres:Kan niet omgaan met meerdere resultaat groepen.
postgresql.con.pass:Het password, welke verplicht is, ontbreekt.
ppostgresql.con.refused:Verbinding geweigerd. Controleer dat de hostnaam en poort correct zijn, en dat de postmaster is opgestart met de -i vlag, welke TCP/IP networking aanzet.
postgresql.con.strobj:Het object kon niet worden opgeslagen. Controleer dat alle benodigde tabellen aangemaakt zijn in de database.
postgresql.con.strobjex:Kon niet object opslaan - {0}
postgresql.con.toolong:Het SQL Statement is te lang - {0}
postgresql.con.tuple:Tuple ontvangen voor MetaData.
postgresql.con.type:Onbekend antwoord type {0}
postgresql.con.user:De user, welke verplicht is, ontbreekt.
postgresql.fp.error:FastPath aanroep retourneerde {0}
postgresql.fp.expint:Fastpath aanroep {0} - Geen resultaat werd teruggegeven, terwijl we een integer verwacht hadden.
postgresql.fp.protocol:FastPath protocol fout: {0}
postgresql.fp.send:Kon geen fastpath aanroep verzenden {0} {1}
postgresql.fp.unknown:De fastpath functie {0} is onbekend.
postgresql.geo.box:Conversie van box faalde - {0}
postgresql.geo.circle:Conversie van circle faalde - {0}
postgresql.geo.line:Conversie van line faalde - {0}
postgresql.geo.lseg:Conversie van lseg faalde - {0}
postgresql.geo.path:Kan niet zeggen of path open of gesloten is.
postgresql.geo.point:Conversie van point faalde - {0}
postgresql.jvm.version:De postgresql.jar file bevat niet de correcte JDBC classen voor deze JVM. Probeer opnieuw te bouwen. Als dat niet werkt, probeer de versie te forceren via de command line met het argument -Djava.version=1.1 of -Djava.version=1.2\nAfgevuurde exceptie was {0}
postgresql.lo.init:Kon LargeObject API niet initialiseren
postgresql.money:Conversie van money faalde - {0}.
postgresql.prep.is:InputStream als parameter wordt niet ondersteund
postgresql.prep.param:Geen waarde opgegeven voor parameter {0}.
postgresql.prep.range:Parameterindex is buiten bereik.
postgresql.prep.type:Onbekende Types waarde.
postgresql.res.badbigdec:Foute BigDecimal {0}
postgresql.res.badbyte:Foute Byte {0}
postgresql.res.baddate:Foutief Date Formaat op {0} in {1}
postgresql.res.baddouble:Foute Double {0}
postgresql.res.badfloat:Foute Float {0}
postgresql.res.badint:Foute Integer {0}
postgresql.res.badlong:Foute Long {0}
postgresql.res.badshort:Foute Short {0}
postgresql.res.badtime:Foute Time {0}
postgresql.res.badtimestamp:Foutief Timestamp Formaat op {0} in {1}
postgresql.res.colname:De kolom naam {0} is niet gevonden.
postgresql.res.colrange:De kolom index is buiten bereik.
postgresql.serial.interface:Je can geen interface serializeren.
postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {0} is {1} characters.
postgresql.serial.noclass:Geen class gevonden voor {0}.
postgresql.serial.table:De tabel voor {0} is niet in de database. Neem contact op met de DBA, omdat de database in een inconsistente staat verkeert.
postgresql.serial.underscore:Class namen mogen geen _ in zich hebben. Jij voerde {0} in.
postgresql.stat.batch.empty:De batch is leeg. Er is niets om uit te voeren.
postgresql.stat.batch.error:Batch invoer {0} {1} werd afgebroken.
postgresql.stat.maxfieldsize:Een poging om setMaxFieldSize() faalde - compiletime standaardwaarde van kracht.
postgresql.stat.noresult:Geen resultaten werden teruggegeven door de query.
postgresql.stat.result:Door het statement werd een resultaat teruggegeven, terwijl er geen verwacht werd.
postgresql.stream.eof:De achterkant heeft de verbinding verbroken. Mogelijk was de actie die je probeerde de oorzaak hiervan.
postgresql.stream.flush:Een I/O fout trad op tijdens het legen van de uitvoer - {0}
postgresql.stream.ioerror:Een I/O fout trad op tijdens het lezen van de achterkant - {0}
postgresql.stream.toomuch:Teveel gegevens werden ontvangen
postgresql.unusual:Iets ongewoons is opgetreden, wat deze driver doet falen. Rapporteer deze fout AUB: {0}
postgresql.unimplemented:Deze methode is nog niet geimplementeerd
postgresql.unexpected:Een onverwacht resultaat werd teruggegeven door een query