Commit f37c1c48 authored by Bruce Momjian's avatar Bruce Momjian

Run pgjindent for Java folks.

parent b4295d05
...@@ -233,7 +233,7 @@ public class Unicode ...@@ -233,7 +233,7 @@ public class Unicode
catch (ClassNotFoundException cnfe) catch (ClassNotFoundException cnfe)
{ {
log("Unable to load driver", cnfe); log("Unable to load driver", cnfe);
return; return ;
} }
try try
{ {
......
...@@ -6,7 +6,7 @@ import java.text.*; ...@@ -6,7 +6,7 @@ import java.text.*;
/* /*
* *
* $Id: basic.java,v 1.12 2002/07/23 03:59:54 barry Exp $ * $Id: basic.java,v 1.13 2002/09/06 21:23:05 momjian Exp $
* *
* This example tests the basic components of the JDBC driver, and shows * This example tests the basic components of the JDBC driver, and shows
* how even the simplest of queries can be implemented. * how even the simplest of queries can be implemented.
...@@ -137,6 +137,7 @@ public class basic ...@@ -137,6 +137,7 @@ public class basic
// result if you don't know what column number a value is in // result if you don't know what column number a value is in
System.out.println("performing another query"); System.out.println("performing another query");
rs = st.executeQuery("select * from basic where b>1"); rs = st.executeQuery("select * from basic where b>1");
if (rs != null) if (rs != null)
...@@ -164,6 +165,7 @@ public class basic ...@@ -164,6 +165,7 @@ public class basic
// Now test maxrows by setting it to 3 rows // Now test maxrows by setting it to 3 rows
st.setMaxRows(3); st.setMaxRows(3);
System.out.println("performing a query limited to " + st.getMaxRows()); System.out.println("performing a query limited to " + st.getMaxRows());
rs = st.executeQuery("select a, b from basic"); rs = st.executeQuery("select a, b from basic");
......
...@@ -9,7 +9,7 @@ import org.omg.CosNaming.*; ...@@ -9,7 +9,7 @@ import org.omg.CosNaming.*;
* *
* It has no GUI, just a text frontend to keep it simple. * It has no GUI, just a text frontend to keep it simple.
* *
* $Id: StockClient.java,v 1.5 2001/11/19 23:19:20 momjian Exp $ * $Id: StockClient.java,v 1.6 2002/09/06 21:23:05 momjian Exp $
*/ */
public class StockClient public class StockClient
{ {
...@@ -35,14 +35,14 @@ public class StockClient ...@@ -35,14 +35,14 @@ public class StockClient
if (nameServiceObj == null) if (nameServiceObj == null)
{ {
System.err.println("nameServiceObj == null"); System.err.println("nameServiceObj == null");
return; return ;
} }
nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj); nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj);
if (nameService == null) if (nameService == null)
{ {
System.err.println("nameService == null"); System.err.println("nameService == null");
return; return ;
} }
// Resolve the dispenser // Resolve the dispenser
...@@ -53,7 +53,7 @@ public class StockClient ...@@ -53,7 +53,7 @@ public class StockClient
if (dispenser == null) if (dispenser == null)
{ {
System.err.println("dispenser == null"); System.err.println("dispenser == null");
return; return ;
} }
// Now run the front end. // Now run the front end.
......
...@@ -5,7 +5,7 @@ import org.omg.CosNaming.*; ...@@ -5,7 +5,7 @@ import org.omg.CosNaming.*;
/* /*
* This class implements the server side of the example. * This class implements the server side of the example.
* *
* $Id: StockDispenserImpl.java,v 1.4 2001/11/19 23:19:20 momjian Exp $ * $Id: StockDispenserImpl.java,v 1.5 2002/09/06 21:23:05 momjian Exp $
*/ */
public class StockDispenserImpl extends stock._StockDispenserImplBase public class StockDispenserImpl extends stock._StockDispenserImplBase
{ {
...@@ -67,11 +67,11 @@ public class StockDispenserImpl extends stock._StockDispenserImplBase ...@@ -67,11 +67,11 @@ public class StockDispenserImpl extends stock._StockDispenserImplBase
{ {
stock[i].inUse = false; stock[i].inUse = false;
System.out.println("Releasing slot " + i); System.out.println("Releasing slot " + i);
return; return ;
} }
} }
System.out.println("Reserved object not a member of this dispenser"); System.out.println("Reserved object not a member of this dispenser");
return; return ;
} }
/* /*
......
...@@ -5,7 +5,7 @@ import org.omg.CosNaming.*; ...@@ -5,7 +5,7 @@ import org.omg.CosNaming.*;
/* /*
* This class implements the server side of the example. * This class implements the server side of the example.
* *
* $Id: StockServer.java,v 1.4 2001/11/19 23:19:20 momjian Exp $ * $Id: StockServer.java,v 1.5 2002/09/06 21:23:05 momjian Exp $
*/ */
public class StockServer public class StockServer
{ {
...@@ -29,14 +29,14 @@ public class StockServer ...@@ -29,14 +29,14 @@ public class StockServer
if (nameServiceObj == null) if (nameServiceObj == null)
{ {
System.err.println("nameServiceObj = null"); System.err.println("nameServiceObj = null");
return; return ;
} }
org.omg.CosNaming.NamingContext nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj); org.omg.CosNaming.NamingContext nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj);
if (nameService == null) if (nameService == null)
{ {
System.err.println("nameService = null"); System.err.println("nameService = null");
return; return ;
} }
// bind the dispenser into the naming service // bind the dispenser into the naming service
......
...@@ -82,7 +82,7 @@ public class psql ...@@ -82,7 +82,7 @@ public class psql
if (line.startsWith("\\")) if (line.startsWith("\\"))
{ {
processSlashCommand(line); processSlashCommand(line);
return; return ;
} }
boolean type = st.execute(line); boolean type = st.execute(line);
......
...@@ -109,12 +109,14 @@ public class Driver implements java.sql.Driver ...@@ -109,12 +109,14 @@ public class Driver implements java.sql.Driver
{ {
if ((props = parseURL(url, info)) == null) if ((props = parseURL(url, info)) == null)
{ {
if (Driver.logDebug) Driver.debug("Error in url" + url); if (Driver.logDebug)
Driver.debug("Error in url" + url);
return null; return null;
} }
try try
{ {
if (Driver.logDebug) Driver.debug("connect " + url); if (Driver.logDebug)
Driver.debug("connect " + url);
@JDBCCONNECTCLASS@ con = (@JDBCCONNECTCLASS@)(Class.forName("@JDBCCONNECTCLASS@").newInstance()); @JDBCCONNECTCLASS@ con = (@JDBCCONNECTCLASS@)(Class.forName("@JDBCCONNECTCLASS@").newInstance());
con.openConnection (host(), port(), props, database(), url, this); con.openConnection (host(), port(), props, database(), url, this);
...@@ -122,7 +124,8 @@ public class Driver implements java.sql.Driver ...@@ -122,7 +124,8 @@ public class Driver implements java.sql.Driver
} }
catch (ClassNotFoundException ex) catch (ClassNotFoundException ex)
{ {
if (Driver.logDebug) Driver.debug("error", ex); if (Driver.logDebug)
Driver.debug("error", ex);
throw new PSQLException("postgresql.jvm.version", ex); throw new PSQLException("postgresql.jvm.version", ex);
} }
catch (PSQLException ex1) catch (PSQLException ex1)
...@@ -133,7 +136,8 @@ public class Driver implements java.sql.Driver ...@@ -133,7 +136,8 @@ public class Driver implements java.sql.Driver
} }
catch (Exception ex2) catch (Exception ex2)
{ {
if (Driver.logDebug) Driver.debug("error", ex2); if (Driver.logDebug)
Driver.debug("error", ex2);
throw new PSQLException("postgresql.unusual", ex2); throw new PSQLException("postgresql.unusual", ex2);
} }
} }
......
...@@ -7,7 +7,7 @@ import org.postgresql.core.Encoding; ...@@ -7,7 +7,7 @@ import org.postgresql.core.Encoding;
import org.postgresql.fastpath.Fastpath; import org.postgresql.fastpath.Fastpath;
import org.postgresql.largeobject.LargeObjectManager; import org.postgresql.largeobject.LargeObjectManager;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.2 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.3 2002/09/06 21:23:05 momjian Exp $
* This interface defines PostgreSQL extentions to the java.sql.Connection interface. * This interface defines PostgreSQL extentions to the java.sql.Connection interface.
* Any java.sql.Connection object returned by the driver will also implement this * Any java.sql.Connection object returned by the driver will also implement this
* interface * interface
......
package org.postgresql; package org.postgresql;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGNotification.java,v 1.1 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGNotification.java,v 1.2 2002/09/06 21:23:05 momjian Exp $
* This interface defines PostgreSQL extention for Notifications * This interface defines PostgreSQL extention for Notifications
*/ */
public interface PGNotification public interface PGNotification
......
...@@ -3,7 +3,7 @@ package org.postgresql; ...@@ -3,7 +3,7 @@ package org.postgresql;
import java.sql.*; import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.4 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.5 2002/09/06 21:23:05 momjian Exp $
* This interface defines PostgreSQL extentions to the java.sql.Statement interface. * This interface defines PostgreSQL extentions to the java.sql.Statement interface.
* Any java.sql.Statement object returned by the driver will also implement this * Any java.sql.Statement object returned by the driver will also implement this
* interface * interface
......
...@@ -8,7 +8,7 @@ import org.postgresql.util.*; ...@@ -8,7 +8,7 @@ import org.postgresql.util.*;
/* /*
* Converts to and from the character encoding used by the backend. * Converts to and from the character encoding used by the backend.
* *
* $Id: Encoding.java,v 1.5 2002/03/19 02:48:45 momjian Exp $ * $Id: Encoding.java,v 1.6 2002/09/06 21:23:05 momjian Exp $
*/ */
public class Encoding public class Encoding
...@@ -42,14 +42,14 @@ public class Encoding ...@@ -42,14 +42,14 @@ public class Encoding
encodings.put("EUC_KR", new String[] { "EUC_KR" }); encodings.put("EUC_KR", new String[] { "EUC_KR" });
encodings.put("JOHAB", new String[] { "Johab" }); encodings.put("JOHAB", new String[] { "Johab" });
encodings.put("EUC_TW", new String[] { "EUC_TW" }); encodings.put("EUC_TW", new String[] { "EUC_TW" });
encodings.put("SJIS", new String[] { "MS932","SJIS" }); encodings.put("SJIS", new String[] { "MS932", "SJIS" });
encodings.put("BIG5", new String[] { "Big5","MS950","Cp950" }); encodings.put("BIG5", new String[] { "Big5", "MS950", "Cp950" });
encodings.put("GBK", new String[] { "GBK","MS936" }); encodings.put("GBK", new String[] { "GBK", "MS936" });
encodings.put("UHC", new String[] { "MS949","Cp949","Cp949C" }); encodings.put("UHC", new String[] { "MS949", "Cp949", "Cp949C" });
encodings.put("TCVN", new String[] { "Cp1258" }); encodings.put("TCVN", new String[] { "Cp1258" });
encodings.put("WIN1256", new String[] { "Cp1256" }); encodings.put("WIN1256", new String[] { "Cp1256" });
encodings.put("WIN1250", new String[] { "Cp1250" }); encodings.put("WIN1250", new String[] { "Cp1250" });
encodings.put("WIN874", new String[] { "MS874","Cp874" }); encodings.put("WIN874", new String[] { "MS874", "Cp874" });
encodings.put("WIN", new String[] { "Cp1251" }); encodings.put("WIN", new String[] { "Cp1251" });
encodings.put("ALT", new String[] { "Cp866" }); encodings.put("ALT", new String[] { "Cp866" });
// We prefer KOI8-U, since it is a superset of KOI8-R. // We prefer KOI8-U, since it is a superset of KOI8-R.
......
package org.postgresql.core; package org.postgresql.core;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Notification.java,v 1.1 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Notification.java,v 1.2 2002/09/06 21:23:05 momjian Exp $
* This is the implementation of the PGNotification interface * This is the implementation of the PGNotification interface
*/ */
public class Notification implements org.postgresql.PGNotification public class Notification implements org.postgresql.PGNotification
{ {
public Notification(String p_name, int p_pid) { public Notification(String p_name, int p_pid)
{
m_name = p_name; m_name = p_name;
m_pid = p_pid; m_pid = p_pid;
} }
...@@ -14,14 +15,16 @@ public class Notification implements org.postgresql.PGNotification ...@@ -14,14 +15,16 @@ public class Notification implements org.postgresql.PGNotification
/* /*
* Returns name of this notification * Returns name of this notification
*/ */
public String getName() { public String getName()
{
return m_name; return m_name;
} }
/* /*
* Returns the process id of the backend process making this notification * Returns the process id of the backend process making this notification
*/ */
public int getPID() { public int getPID()
{
return m_pid; return m_pid;
} }
......
...@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException; ...@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
* <p>The lifetime of a QueryExecutor object is from sending the query * <p>The lifetime of a QueryExecutor object is from sending the query
* until the response has been received from the backend. * until the response has been received from the backend.
* *
* $Id: QueryExecutor.java,v 1.15 2002/09/02 03:07:36 barry Exp $ * $Id: QueryExecutor.java,v 1.16 2002/09/06 21:23:05 momjian Exp $
*/ */
public class QueryExecutor public class QueryExecutor
...@@ -137,7 +137,8 @@ public class QueryExecutor ...@@ -137,7 +137,8 @@ public class QueryExecutor
try try
{ {
pg_stream.SendChar('Q'); pg_stream.SendChar('Q');
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", new Integer(i + 1));
pg_stream.Send(connection.getEncoding().encode(m_sqlFrags[i])); pg_stream.Send(connection.getEncoding().encode(m_sqlFrags[i]));
......
...@@ -6,7 +6,7 @@ import java.io.IOException; ...@@ -6,7 +6,7 @@ import java.io.IOException;
/** /**
* Sent to the backend to initialize a newly created connection. * Sent to the backend to initialize a newly created connection.
* *
* $Id: StartupPacket.java,v 1.1 2002/03/21 02:40:03 davec Exp $ * $Id: StartupPacket.java,v 1.2 2002/09/06 21:23:05 momjian Exp $
*/ */
public class StartupPacket public class StartupPacket
...@@ -22,7 +22,8 @@ public class StartupPacket ...@@ -22,7 +22,8 @@ public class StartupPacket
private String user; private String user;
private String database; private String database;
public StartupPacket(int protocolMajor, int protocolMinor, String user, String database) { public StartupPacket(int protocolMajor, int protocolMinor, String user, String database)
{
this.protocolMajor = protocolMajor; this.protocolMajor = protocolMajor;
this.protocolMinor = protocolMinor; this.protocolMinor = protocolMinor;
this.user = user; this.user = user;
......
...@@ -118,7 +118,8 @@ public class Fastpath ...@@ -118,7 +118,8 @@ public class Fastpath
case 'V': case 'V':
int l_nextChar = stream.ReceiveChar(); int l_nextChar = stream.ReceiveChar();
if (l_nextChar == 'G') { if (l_nextChar == 'G')
{
int sz = stream.ReceiveIntegerR(4); int sz = stream.ReceiveIntegerR(4);
// Return an Integer if // Return an Integer if
if (resulttype) if (resulttype)
...@@ -131,7 +132,9 @@ public class Fastpath ...@@ -131,7 +132,9 @@ public class Fastpath
} }
//There should be a trailing '0' //There should be a trailing '0'
int l_endChar = stream.ReceiveChar(); int l_endChar = stream.ReceiveChar();
} else { }
else
{
//it must have been a '0', thus no results //it must have been a '0', thus no results
} }
break; break;
...@@ -174,7 +177,8 @@ public class Fastpath ...@@ -174,7 +177,8 @@ public class Fastpath
*/ */
public Object fastpath(String name, boolean resulttype, FastpathArg[] args) throws SQLException public Object fastpath(String name, boolean resulttype, FastpathArg[] args) throws SQLException
{ {
if (Driver.logDebug) Driver.debug("Fastpath: calling "+name); if (Driver.logDebug)
Driver.debug("Fastpath: calling " + name);
return fastpath(getID(name), resulttype, args); return fastpath(getID(name), resulttype, args);
} }
......
...@@ -14,7 +14,7 @@ import org.postgresql.largeobject.LargeObjectManager; ...@@ -14,7 +14,7 @@ import org.postgresql.largeobject.LargeObjectManager;
import org.postgresql.util.*; import org.postgresql.util.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.7 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.8 2002/09/06 21:23:05 momjian 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.AbstractJdbc2Connection which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection * methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
...@@ -130,23 +130,29 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -130,23 +130,29 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
//Read loglevel arg and set the loglevel based on this value //Read loglevel arg and set the loglevel based on this value
//in addition to setting the log level enable output to //in addition to setting the log level enable output to
//standard out if no other printwriter is set //standard out if no other printwriter is set
String l_logLevelProp = info.getProperty("loglevel","0"); String l_logLevelProp = info.getProperty("loglevel", "0");
int l_logLevel = 0; int l_logLevel = 0;
try { try
{
l_logLevel = Integer.parseInt(l_logLevelProp); l_logLevel = Integer.parseInt(l_logLevelProp);
if (l_logLevel > org.postgresql.Driver.DEBUG || l_logLevel < org.postgresql.Driver.INFO) { if (l_logLevel > org.postgresql.Driver.DEBUG || l_logLevel < org.postgresql.Driver.INFO)
{
l_logLevel = 0; l_logLevel = 0;
} }
} catch (Exception l_e) { }
catch (Exception l_e)
{
//invalid value for loglevel ignore //invalid value for loglevel ignore
} }
if (l_logLevel > 0) { if (l_logLevel > 0)
{
org.postgresql.Driver.setLogLevel(l_logLevel); org.postgresql.Driver.setLogLevel(l_logLevel);
enableDriverManagerLogging(); enableDriverManagerLogging();
} }
//Print out the driver version number //Print out the driver version number
if (org.postgresql.Driver.logInfo) org.postgresql.Driver.info(org.postgresql.Driver.getVersion()); if (org.postgresql.Driver.logInfo)
org.postgresql.Driver.info(org.postgresql.Driver.getVersion());
// Now make the initial connection // Now make the initial connection
try try
...@@ -205,7 +211,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -205,7 +211,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
rst[0] = (byte)pg_stream.ReceiveChar(); rst[0] = (byte)pg_stream.ReceiveChar();
rst[1] = (byte)pg_stream.ReceiveChar(); rst[1] = (byte)pg_stream.ReceiveChar();
salt = new String(rst, 0, 2); salt = new String(rst, 0, 2);
if (org.postgresql.Driver.logDebug) org.postgresql.Driver.debug("Crypt salt=" + salt); if (org.postgresql.Driver.logDebug)
org.postgresql.Driver.debug("Crypt salt=" + salt);
} }
// Or get the md5 password salt if there is one // Or get the md5 password salt if there is one
...@@ -217,7 +224,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -217,7 +224,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
md5Salt[2] = (byte)pg_stream.ReceiveChar(); md5Salt[2] = (byte)pg_stream.ReceiveChar();
md5Salt[3] = (byte)pg_stream.ReceiveChar(); md5Salt[3] = (byte)pg_stream.ReceiveChar();
salt = new String(md5Salt, 0, 4); salt = new String(md5Salt, 0, 4);
if (org.postgresql.Driver.logDebug) org.postgresql.Driver.debug("MD5 salt=" + salt); if (org.postgresql.Driver.logDebug)
org.postgresql.Driver.debug("MD5 salt=" + salt);
} }
// now send the auth packet // now send the auth packet
...@@ -227,15 +235,18 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -227,15 +235,18 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
break; break;
case AUTH_REQ_KRB4: case AUTH_REQ_KRB4:
if (org.postgresql.Driver.logDebug) org.postgresql.Driver.debug("postgresql: KRB4"); if (org.postgresql.Driver.logDebug)
org.postgresql.Driver.debug("postgresql: KRB4");
throw new PSQLException("postgresql.con.kerb4"); throw new PSQLException("postgresql.con.kerb4");
case AUTH_REQ_KRB5: case AUTH_REQ_KRB5:
if (org.postgresql.Driver.logDebug) org.postgresql.Driver.debug("postgresql: KRB5"); if (org.postgresql.Driver.logDebug)
org.postgresql.Driver.debug("postgresql: KRB5");
throw new PSQLException("postgresql.con.kerb5"); throw new PSQLException("postgresql.con.kerb5");
case AUTH_REQ_PASSWORD: case AUTH_REQ_PASSWORD:
if (org.postgresql.Driver.logDebug) org.postgresql.Driver.debug("postgresql: PASSWORD"); if (org.postgresql.Driver.logDebug)
org.postgresql.Driver.debug("postgresql: PASSWORD");
pg_stream.SendInteger(5 + password.length(), 4); pg_stream.SendInteger(5 + password.length(), 4);
pg_stream.Send(password.getBytes()); pg_stream.Send(password.getBytes());
pg_stream.SendInteger(0, 1); pg_stream.SendInteger(0, 1);
...@@ -243,7 +254,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -243,7 +254,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
break; break;
case AUTH_REQ_CRYPT: case AUTH_REQ_CRYPT:
if (org.postgresql.Driver.logDebug) org.postgresql.Driver.debug("postgresql: CRYPT"); if (org.postgresql.Driver.logDebug)
org.postgresql.Driver.debug("postgresql: CRYPT");
String crypted = UnixCrypt.crypt(salt, password); String crypted = UnixCrypt.crypt(salt, password);
pg_stream.SendInteger(5 + crypted.length(), 4); pg_stream.SendInteger(5 + crypted.length(), 4);
pg_stream.Send(crypted.getBytes()); pg_stream.Send(crypted.getBytes());
...@@ -252,7 +264,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -252,7 +264,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
break; break;
case AUTH_REQ_MD5: case AUTH_REQ_MD5:
if (org.postgresql.Driver.logDebug) org.postgresql.Driver.debug("postgresql: MD5"); if (org.postgresql.Driver.logDebug)
org.postgresql.Driver.debug("postgresql: MD5");
byte[] digest = MD5Digest.encode(PG_USER, password, md5Salt); byte[] digest = MD5Digest.encode(PG_USER, password, md5Salt);
pg_stream.SendInteger(5 + digest.length, 4); pg_stream.SendInteger(5 + digest.length, 4);
pg_stream.Send(digest); pg_stream.Send(digest);
...@@ -280,7 +293,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -280,7 +293,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
// As of protocol version 2.0, we should now receive the cancellation key and the pid // As of protocol version 2.0, we should now receive the cancellation key and the pid
int beresp; int beresp;
do { do
{
beresp = pg_stream.ReceiveChar(); beresp = pg_stream.ReceiveChar();
switch (beresp) switch (beresp)
{ {
...@@ -296,10 +310,12 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -296,10 +310,12 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
default: default:
throw new PSQLException("postgresql.con.setup"); throw new PSQLException("postgresql.con.setup");
} }
} while (beresp == 'N'); }
while (beresp == 'N');
// Expect ReadyForQuery packet // Expect ReadyForQuery packet
do { do
{
beresp = pg_stream.ReceiveChar(); beresp = pg_stream.ReceiveChar();
switch (beresp) switch (beresp)
{ {
...@@ -313,7 +329,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -313,7 +329,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
default: default:
throw new PSQLException("postgresql.con.setup"); throw new PSQLException("postgresql.con.setup");
} }
} while (beresp == 'N'); }
while (beresp == 'N');
// "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte, // "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte,
// otherwise it's hardcoded to 'SQL_ASCII'. // otherwise it's hardcoded to 'SQL_ASCII'.
// If the backend doesn't know about multibyte we can't assume anything about the encoding // If the backend doesn't know about multibyte we can't assume anything about the encoding
...@@ -877,7 +894,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -877,7 +894,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
public void setAutoCommit(boolean autoCommit) throws SQLException public void setAutoCommit(boolean autoCommit) throws SQLException
{ {
if (this.autoCommit == autoCommit) if (this.autoCommit == autoCommit)
return; return ;
if (autoCommit) if (autoCommit)
ExecSQL("end"); ExecSQL("end");
else else
...@@ -920,7 +937,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -920,7 +937,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
public void commit() throws SQLException public void commit() throws SQLException
{ {
if (autoCommit) if (autoCommit)
return; return ;
if (haveMinimumServerVersion("7.1")) if (haveMinimumServerVersion("7.1"))
{ {
ExecSQL("commit;begin;" + getIsolationLevelSQL()); ExecSQL("commit;begin;" + getIsolationLevelSQL());
...@@ -944,7 +961,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -944,7 +961,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
public void rollback() throws SQLException public void rollback() throws SQLException
{ {
if (autoCommit) if (autoCommit)
return; return ;
if (haveMinimumServerVersion("7.1")) if (haveMinimumServerVersion("7.1"))
{ {
ExecSQL("rollback; begin;" + getIsolationLevelSQL()); ExecSQL("rollback; begin;" + getIsolationLevelSQL());
...@@ -1222,8 +1239,10 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -1222,8 +1239,10 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
//Because the get/setLogStream methods are deprecated in JDBC2 //Because the get/setLogStream methods are deprecated in JDBC2
//we use them for JDBC1 here and override this method in the jdbc2 //we use them for JDBC1 here and override this method in the jdbc2
//version of this class //version of this class
protected void enableDriverManagerLogging() { protected void enableDriverManagerLogging()
if (DriverManager.getLogStream() == null) { {
if (DriverManager.getLogStream() == null)
{
DriverManager.setLogStream(System.out); DriverManager.setLogStream(System.out);
} }
} }
...@@ -1313,15 +1332,18 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -1313,15 +1332,18 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
}; };
//Methods to support postgres notifications //Methods to support postgres notifications
public void addNotification(org.postgresql.PGNotification p_notification) { public void addNotification(org.postgresql.PGNotification p_notification)
{
if (m_notifications == null) if (m_notifications == null)
m_notifications = new Vector(); m_notifications = new Vector();
m_notifications.addElement(p_notification); m_notifications.addElement(p_notification);
} }
public PGNotification[] getNotifications() { public PGNotification[] getNotifications()
{
PGNotification[] l_return = null; PGNotification[] l_return = null;
if (m_notifications != null) { if (m_notifications != null)
{
l_return = new PGNotification[m_notifications.size()]; l_return = new PGNotification[m_notifications.size()];
m_notifications.copyInto(l_return); m_notifications.copyInto(l_return);
} }
......
...@@ -11,12 +11,12 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -11,12 +11,12 @@ public abstract class AbstractJdbc1DatabaseMetaData
{ {
private static final String keywords = "abort,acl,add,aggregate,append,archive," + private static final String keywords = "abort,acl,add,aggregate,append,archive," +
"arch_store,backward,binary,change,cluster,"+ "arch_store,backward,binary,change,cluster," +
"copy,database,delimiter,delimiters,do,extend,"+ "copy,database,delimiter,delimiters,do,extend," +
"explain,forward,heavy,index,inherits,isnull,"+ "explain,forward,heavy,index,inherits,isnull," +
"light,listen,load,merge,nothing,notify,"+ "light,listen,load,merge,nothing,notify," +
"notnull,oids,purge,rename,replace,retrieve,"+ "notnull,oids,purge,rename,replace,retrieve," +
"returns,rule,recipe,setof,stdin,stdout,store,"+ "returns,rule,recipe,setof,stdin,stdout,store," +
"vacuum,verbose,version"; "vacuum,verbose,version";
protected AbstractJdbc1Connection connection; // The connection association protected AbstractJdbc1Connection connection; // The connection association
...@@ -42,7 +42,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -42,7 +42,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean allProceduresAreCallable() throws SQLException public boolean allProceduresAreCallable() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("allProceduresAreCallable"); if (Driver.logDebug)
Driver.debug("allProceduresAreCallable");
return true; // For now... return true; // For now...
} }
...@@ -55,7 +56,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -55,7 +56,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean allTablesAreSelectable() throws SQLException public boolean allTablesAreSelectable() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("allTablesAreSelectable"); if (Driver.logDebug)
Driver.debug("allTablesAreSelectable");
return true; // For now... return true; // For now...
} }
...@@ -68,7 +70,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -68,7 +70,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public String getURL() throws SQLException public String getURL() throws SQLException
{ {
String url = connection.getURL(); String url = connection.getURL();
if (Driver.logDebug) Driver.debug("getURL " + url); if (Driver.logDebug)
Driver.debug("getURL " + url);
return url; return url;
} }
...@@ -81,7 +84,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -81,7 +84,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public String getUserName() throws SQLException public String getUserName() throws SQLException
{ {
String userName = connection.getUserName(); String userName = connection.getUserName();
if (Driver.logDebug) Driver.debug("getUserName " + userName); if (Driver.logDebug)
Driver.debug("getUserName " + userName);
return userName; return userName;
} }
...@@ -94,7 +98,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -94,7 +98,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean isReadOnly() throws SQLException public boolean isReadOnly() throws SQLException
{ {
boolean isReadOnly = connection.isReadOnly(); boolean isReadOnly = connection.isReadOnly();
if (Driver.logDebug) Driver.debug("isReadOnly " + isReadOnly); if (Driver.logDebug)
Driver.debug("isReadOnly " + isReadOnly);
return isReadOnly; return isReadOnly;
} }
...@@ -107,7 +112,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -107,7 +112,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean nullsAreSortedHigh() throws SQLException public boolean nullsAreSortedHigh() throws SQLException
{ {
boolean nullSortedHigh = connection.haveMinimumServerVersion("7.2"); boolean nullSortedHigh = connection.haveMinimumServerVersion("7.2");
if (Driver.logDebug) Driver.debug("nullsAreSortedHigh " + nullSortedHigh); if (Driver.logDebug)
Driver.debug("nullsAreSortedHigh " + nullSortedHigh);
return nullSortedHigh; return nullSortedHigh;
} }
...@@ -119,7 +125,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -119,7 +125,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean nullsAreSortedLow() throws SQLException public boolean nullsAreSortedLow() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("nullsAreSortedLow false"); if (Driver.logDebug)
Driver.debug("nullsAreSortedLow false");
return false; return false;
} }
...@@ -131,7 +138,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -131,7 +138,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean nullsAreSortedAtStart() throws SQLException public boolean nullsAreSortedAtStart() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("nullsAreSortedAtStart false"); if (Driver.logDebug)
Driver.debug("nullsAreSortedAtStart false");
return false; return false;
} }
...@@ -144,7 +152,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -144,7 +152,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean nullsAreSortedAtEnd() throws SQLException public boolean nullsAreSortedAtEnd() throws SQLException
{ {
boolean nullsAreSortedAtEnd = ! connection.haveMinimumServerVersion("7.2"); boolean nullsAreSortedAtEnd = ! connection.haveMinimumServerVersion("7.2");
if (Driver.logDebug) Driver.debug("nullsAreSortedAtEnd " + nullsAreSortedAtEnd); if (Driver.logDebug)
Driver.debug("nullsAreSortedAtEnd " + nullsAreSortedAtEnd);
return nullsAreSortedAtEnd; return nullsAreSortedAtEnd;
} }
...@@ -157,7 +166,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -157,7 +166,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public String getDatabaseProductName() throws SQLException public String getDatabaseProductName() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getDatabaseProductName PostgresSQL"); if (Driver.logDebug)
Driver.debug("getDatabaseProductName PostgresSQL");
return "PostgreSQL"; return "PostgreSQL";
} }
...@@ -170,7 +180,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -170,7 +180,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public String getDatabaseProductVersion() throws SQLException public String getDatabaseProductVersion() throws SQLException
{ {
String versionNumber = connection.getDBVersionNumber(); String versionNumber = connection.getDBVersionNumber();
if (Driver.logDebug) Driver.debug("getDatabaseProductVersion " + versionNumber); if (Driver.logDebug)
Driver.debug("getDatabaseProductVersion " + versionNumber);
return versionNumber; return versionNumber;
} }
...@@ -184,7 +195,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -184,7 +195,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public String getDriverName() throws SQLException public String getDriverName() throws SQLException
{ {
String driverName = "PostgreSQL Native Driver"; String driverName = "PostgreSQL Native Driver";
if (Driver.logDebug) Driver.debug("getDriverName" + driverName); if (Driver.logDebug)
Driver.debug("getDriverName" + driverName);
return driverName; return driverName;
} }
...@@ -198,7 +210,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -198,7 +210,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public String getDriverVersion() throws SQLException public String getDriverVersion() throws SQLException
{ {
String driverVersion = connection.this_driver.getVersion(); String driverVersion = connection.this_driver.getVersion();
if (Driver.logDebug) Driver.debug("getDriverVersion " + driverVersion); if (Driver.logDebug)
Driver.debug("getDriverVersion " + driverVersion);
return driverVersion; return driverVersion;
} }
...@@ -210,7 +223,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -210,7 +223,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public int getDriverMajorVersion() public int getDriverMajorVersion()
{ {
int majorVersion = connection.this_driver.getMajorVersion(); int majorVersion = connection.this_driver.getMajorVersion();
if (Driver.logDebug) Driver.debug("getMajorVersion " + majorVersion); if (Driver.logDebug)
Driver.debug("getMajorVersion " + majorVersion);
return majorVersion; return majorVersion;
} }
...@@ -222,7 +236,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -222,7 +236,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public int getDriverMinorVersion() public int getDriverMinorVersion()
{ {
int minorVersion = connection.this_driver.getMinorVersion(); int minorVersion = connection.this_driver.getMinorVersion();
if (Driver.logDebug) Driver.debug("getMinorVersion " + minorVersion); if (Driver.logDebug)
Driver.debug("getMinorVersion " + minorVersion);
return minorVersion; return minorVersion;
} }
...@@ -235,7 +250,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -235,7 +250,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean usesLocalFiles() throws SQLException public boolean usesLocalFiles() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("usesLocalFiles " + false); if (Driver.logDebug)
Driver.debug("usesLocalFiles " + false);
return false; return false;
} }
...@@ -248,7 +264,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -248,7 +264,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean usesLocalFilePerTable() throws SQLException public boolean usesLocalFilePerTable() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("usesLocalFilePerTable " + false); if (Driver.logDebug)
Driver.debug("usesLocalFilePerTable " + false);
return false; return false;
} }
...@@ -266,7 +283,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -266,7 +283,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsMixedCaseIdentifiers() throws SQLException public boolean supportsMixedCaseIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsMixedCaseIdentifiers " + false); if (Driver.logDebug)
Driver.debug("supportsMixedCaseIdentifiers " + false);
return false; return false;
} }
...@@ -278,7 +296,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -278,7 +296,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean storesUpperCaseIdentifiers() throws SQLException public boolean storesUpperCaseIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("storesUpperCaseIdentifiers " + false); if (Driver.logDebug)
Driver.debug("storesUpperCaseIdentifiers " + false);
return false; return false;
} }
...@@ -290,7 +309,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -290,7 +309,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean storesLowerCaseIdentifiers() throws SQLException public boolean storesLowerCaseIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("storesLowerCaseIdentifiers " + true); if (Driver.logDebug)
Driver.debug("storesLowerCaseIdentifiers " + true);
return true; return true;
} }
...@@ -302,7 +322,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -302,7 +322,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean storesMixedCaseIdentifiers() throws SQLException public boolean storesMixedCaseIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("storesMixedCaseIdentifiers " + false); if (Driver.logDebug)
Driver.debug("storesMixedCaseIdentifiers " + false);
return false; return false;
} }
...@@ -316,7 +337,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -316,7 +337,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsMixedCaseQuotedIdentifiers " + true); if (Driver.logDebug)
Driver.debug("supportsMixedCaseQuotedIdentifiers " + true);
return true; return true;
} }
...@@ -328,7 +350,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -328,7 +350,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean storesUpperCaseQuotedIdentifiers() throws SQLException public boolean storesUpperCaseQuotedIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("storesUpperCaseQuotedIdentifiers " + false); if (Driver.logDebug)
Driver.debug("storesUpperCaseQuotedIdentifiers " + false);
return false; return false;
} }
...@@ -340,7 +363,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -340,7 +363,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean storesLowerCaseQuotedIdentifiers() throws SQLException public boolean storesLowerCaseQuotedIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("storesLowerCaseQuotedIdentifiers " + false); if (Driver.logDebug)
Driver.debug("storesLowerCaseQuotedIdentifiers " + false);
return false; return false;
} }
...@@ -352,7 +376,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -352,7 +376,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean storesMixedCaseQuotedIdentifiers() throws SQLException public boolean storesMixedCaseQuotedIdentifiers() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("storesMixedCaseQuotedIdentifiers " + false); if (Driver.logDebug)
Driver.debug("storesMixedCaseQuotedIdentifiers " + false);
return false; return false;
} }
...@@ -366,7 +391,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -366,7 +391,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public String getIdentifierQuoteString() throws SQLException public String getIdentifierQuoteString() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getIdentifierQuoteString \"" ); if (Driver.logDebug)
Driver.debug("getIdentifierQuoteString \"" );
return "\""; return "\"";
} }
...@@ -393,25 +419,29 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -393,25 +419,29 @@ public abstract class AbstractJdbc1DatabaseMetaData
public String getNumericFunctions() throws SQLException public String getNumericFunctions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getNumericFunctions"); if (Driver.logDebug)
Driver.debug("getNumericFunctions");
return ""; return "";
} }
public String getStringFunctions() throws SQLException public String getStringFunctions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getStringFunctions"); if (Driver.logDebug)
Driver.debug("getStringFunctions");
return ""; return "";
} }
public String getSystemFunctions() throws SQLException public String getSystemFunctions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getSystemFunctions"); if (Driver.logDebug)
Driver.debug("getSystemFunctions");
return ""; return "";
} }
public String getTimeDateFunctions() throws SQLException public String getTimeDateFunctions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getTimeDateFunctions"); if (Driver.logDebug)
Driver.debug("getTimeDateFunctions");
return ""; return "";
} }
...@@ -424,7 +454,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -424,7 +454,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public String getSearchStringEscape() throws SQLException public String getSearchStringEscape() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getSearchStringEscape"); if (Driver.logDebug)
Driver.debug("getSearchStringEscape");
return "\\"; return "\\";
} }
...@@ -441,7 +472,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -441,7 +472,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public String getExtraNameCharacters() throws SQLException public String getExtraNameCharacters() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getExtraNameCharacters"); if (Driver.logDebug)
Driver.debug("getExtraNameCharacters");
return ""; return "";
} }
...@@ -454,7 +486,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -454,7 +486,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsAlterTableWithAddColumn() throws SQLException public boolean supportsAlterTableWithAddColumn() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsAlterTableWithAddColumn " + true); if (Driver.logDebug)
Driver.debug("supportsAlterTableWithAddColumn " + true);
return true; return true;
} }
...@@ -467,7 +500,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -467,7 +500,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsAlterTableWithDropColumn() throws SQLException public boolean supportsAlterTableWithDropColumn() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsAlterTableWithDropColumn " + false); if (Driver.logDebug)
Driver.debug("supportsAlterTableWithDropColumn " + false);
return false; return false;
} }
...@@ -491,7 +525,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -491,7 +525,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsColumnAliasing() throws SQLException public boolean supportsColumnAliasing() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsColumnAliasing " + true); if (Driver.logDebug)
Driver.debug("supportsColumnAliasing " + true);
return true; return true;
} }
...@@ -504,19 +539,22 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -504,19 +539,22 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean nullPlusNonNullIsNull() throws SQLException public boolean nullPlusNonNullIsNull() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("nullPlusNonNullIsNull " + true); if (Driver.logDebug)
Driver.debug("nullPlusNonNullIsNull " + true);
return true; return true;
} }
public boolean supportsConvert() throws SQLException public boolean supportsConvert() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsConvert " + false); if (Driver.logDebug)
Driver.debug("supportsConvert " + false);
return false; return false;
} }
public boolean supportsConvert(int fromType, int toType) throws SQLException public boolean supportsConvert(int fromType, int toType) throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsConvert " + false); if (Driver.logDebug)
Driver.debug("supportsConvert " + false);
return false; return false;
} }
...@@ -529,7 +567,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -529,7 +567,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsTableCorrelationNames() throws SQLException public boolean supportsTableCorrelationNames() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsTableCorrelationNames " + true); if (Driver.logDebug)
Driver.debug("supportsTableCorrelationNames " + true);
return true; return true;
} }
...@@ -542,7 +581,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -542,7 +581,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsDifferentTableCorrelationNames() throws SQLException public boolean supportsDifferentTableCorrelationNames() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsDifferentTableCorrelationNames " + false); if (Driver.logDebug)
Driver.debug("supportsDifferentTableCorrelationNames " + false);
return false; return false;
} }
...@@ -556,7 +596,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -556,7 +596,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsExpressionsInOrderBy() throws SQLException public boolean supportsExpressionsInOrderBy() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsExpressionsInOrderBy " + true); if (Driver.logDebug)
Driver.debug("supportsExpressionsInOrderBy " + true);
return true; return true;
} }
...@@ -569,7 +610,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -569,7 +610,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsOrderByUnrelated() throws SQLException public boolean supportsOrderByUnrelated() throws SQLException
{ {
boolean supportsOrderByUnrelated = connection.haveMinimumServerVersion("6.4"); boolean supportsOrderByUnrelated = connection.haveMinimumServerVersion("6.4");
if (Driver.logDebug) Driver.debug("supportsOrderByUnrelated " + supportsOrderByUnrelated); if (Driver.logDebug)
Driver.debug("supportsOrderByUnrelated " + supportsOrderByUnrelated);
return supportsOrderByUnrelated; return supportsOrderByUnrelated;
} }
...@@ -582,7 +624,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -582,7 +624,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsGroupBy() throws SQLException public boolean supportsGroupBy() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsGroupBy " + true); if (Driver.logDebug)
Driver.debug("supportsGroupBy " + true);
return true; return true;
} }
...@@ -595,7 +638,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -595,7 +638,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsGroupByUnrelated() throws SQLException public boolean supportsGroupByUnrelated() throws SQLException
{ {
boolean supportsGroupByUnrelated = connection.haveMinimumServerVersion("6.4"); boolean supportsGroupByUnrelated = connection.haveMinimumServerVersion("6.4");
if (Driver.logDebug) Driver.debug("supportsGroupByUnrelated " + supportsGroupByUnrelated); if (Driver.logDebug)
Driver.debug("supportsGroupByUnrelated " + supportsGroupByUnrelated);
return supportsGroupByUnrelated; return supportsGroupByUnrelated;
} }
...@@ -612,7 +656,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -612,7 +656,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsGroupByBeyondSelect() throws SQLException public boolean supportsGroupByBeyondSelect() throws SQLException
{ {
boolean supportsGroupByBeyondSelect = connection.haveMinimumServerVersion("6.4"); boolean supportsGroupByBeyondSelect = connection.haveMinimumServerVersion("6.4");
if (Driver.logDebug) Driver.debug("supportsGroupByUnrelated " + supportsGroupByBeyondSelect); if (Driver.logDebug)
Driver.debug("supportsGroupByUnrelated " + supportsGroupByBeyondSelect);
return supportsGroupByBeyondSelect; return supportsGroupByBeyondSelect;
} }
...@@ -626,7 +671,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -626,7 +671,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsLikeEscapeClause() throws SQLException public boolean supportsLikeEscapeClause() throws SQLException
{ {
boolean supportsLikeEscapeClause = connection.haveMinimumServerVersion("7.1"); boolean supportsLikeEscapeClause = connection.haveMinimumServerVersion("7.1");
if (Driver.logDebug) Driver.debug("supportsLikeEscapeClause " + supportsLikeEscapeClause); if (Driver.logDebug)
Driver.debug("supportsLikeEscapeClause " + supportsLikeEscapeClause);
return supportsLikeEscapeClause; return supportsLikeEscapeClause;
} }
...@@ -640,7 +686,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -640,7 +686,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsMultipleResultSets() throws SQLException public boolean supportsMultipleResultSets() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsMultipleResultSets " + false); if (Driver.logDebug)
Driver.debug("supportsMultipleResultSets " + false);
return false; return false;
} }
...@@ -654,7 +701,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -654,7 +701,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsMultipleTransactions() throws SQLException public boolean supportsMultipleTransactions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsMultipleTransactions " + true); if (Driver.logDebug)
Driver.debug("supportsMultipleTransactions " + true);
return true; return true;
} }
...@@ -670,7 +718,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -670,7 +718,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsNonNullableColumns() throws SQLException public boolean supportsNonNullableColumns() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsNonNullableColumns true"); if (Driver.logDebug)
Driver.debug("supportsNonNullableColumns true");
return true; return true;
} }
...@@ -688,7 +737,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -688,7 +737,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsMinimumSQLGrammar() throws SQLException public boolean supportsMinimumSQLGrammar() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsMinimumSQLGrammar TRUE"); if (Driver.logDebug)
Driver.debug("supportsMinimumSQLGrammar TRUE");
return true; return true;
} }
...@@ -701,7 +751,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -701,7 +751,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsCoreSQLGrammar() throws SQLException public boolean supportsCoreSQLGrammar() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsCoreSQLGrammar FALSE "); if (Driver.logDebug)
Driver.debug("supportsCoreSQLGrammar FALSE ");
return false; return false;
} }
...@@ -715,7 +766,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -715,7 +766,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsExtendedSQLGrammar() throws SQLException public boolean supportsExtendedSQLGrammar() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsExtendedSQLGrammar FALSE"); if (Driver.logDebug)
Driver.debug("supportsExtendedSQLGrammar FALSE");
return false; return false;
} }
...@@ -734,7 +786,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -734,7 +786,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsANSI92EntryLevelSQL() throws SQLException public boolean supportsANSI92EntryLevelSQL() throws SQLException
{ {
boolean schemas = connection.haveMinimumServerVersion("7.3"); boolean schemas = connection.haveMinimumServerVersion("7.3");
if (Driver.logDebug) Driver.debug("supportsANSI92EntryLevelSQL " + schemas); if (Driver.logDebug)
Driver.debug("supportsANSI92EntryLevelSQL " + schemas);
return schemas; return schemas;
} }
...@@ -747,7 +800,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -747,7 +800,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsANSI92IntermediateSQL() throws SQLException public boolean supportsANSI92IntermediateSQL() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsANSI92IntermediateSQL false "); if (Driver.logDebug)
Driver.debug("supportsANSI92IntermediateSQL false ");
return false; return false;
} }
...@@ -759,7 +813,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -759,7 +813,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsANSI92FullSQL() throws SQLException public boolean supportsANSI92FullSQL() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsANSI92FullSQL false "); if (Driver.logDebug)
Driver.debug("supportsANSI92FullSQL false ");
return false; return false;
} }
...@@ -772,7 +827,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -772,7 +827,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsIntegrityEnhancementFacility() throws SQLException public boolean supportsIntegrityEnhancementFacility() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsIntegrityEnhancementFacility false "); if (Driver.logDebug)
Driver.debug("supportsIntegrityEnhancementFacility false ");
return false; return false;
} }
...@@ -785,7 +841,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -785,7 +841,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsOuterJoins() throws SQLException public boolean supportsOuterJoins() throws SQLException
{ {
boolean supportsOuterJoins = connection.haveMinimumServerVersion("7.1"); boolean supportsOuterJoins = connection.haveMinimumServerVersion("7.1");
if (Driver.logDebug) Driver.debug("supportsOuterJoins " + supportsOuterJoins); if (Driver.logDebug)
Driver.debug("supportsOuterJoins " + supportsOuterJoins);
return supportsOuterJoins; return supportsOuterJoins;
} }
...@@ -798,7 +855,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -798,7 +855,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsFullOuterJoins() throws SQLException public boolean supportsFullOuterJoins() throws SQLException
{ {
boolean supportsFullOuterJoins = connection.haveMinimumServerVersion("7.1"); boolean supportsFullOuterJoins = connection.haveMinimumServerVersion("7.1");
if (Driver.logDebug) Driver.debug("supportsFullOuterJoins " + supportsFullOuterJoins); if (Driver.logDebug)
Driver.debug("supportsFullOuterJoins " + supportsFullOuterJoins);
return supportsFullOuterJoins; return supportsFullOuterJoins;
} }
...@@ -811,7 +869,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -811,7 +869,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public boolean supportsLimitedOuterJoins() throws SQLException public boolean supportsLimitedOuterJoins() throws SQLException
{ {
boolean supportsLimitedOuterJoins = connection.haveMinimumServerVersion("7.1"); boolean supportsLimitedOuterJoins = connection.haveMinimumServerVersion("7.1");
if (Driver.logDebug) Driver.debug("supportsFullOuterJoins " + supportsLimitedOuterJoins); if (Driver.logDebug)
Driver.debug("supportsFullOuterJoins " + supportsLimitedOuterJoins);
return supportsLimitedOuterJoins; return supportsLimitedOuterJoins;
} }
...@@ -825,7 +884,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -825,7 +884,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public String getSchemaTerm() throws SQLException public String getSchemaTerm() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getSchemaTerm schema"); if (Driver.logDebug)
Driver.debug("getSchemaTerm schema");
return "schema"; return "schema";
} }
...@@ -838,7 +898,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -838,7 +898,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public String getProcedureTerm() throws SQLException public String getProcedureTerm() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getProcedureTerm function "); if (Driver.logDebug)
Driver.debug("getProcedureTerm function ");
return "function"; return "function";
} }
...@@ -850,7 +911,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -850,7 +911,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public String getCatalogTerm() throws SQLException public String getCatalogTerm() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("getCatalogTerm database "); if (Driver.logDebug)
Driver.debug("getCatalogTerm database ");
return "database"; return "database";
} }
...@@ -865,7 +927,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -865,7 +927,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{ {
// return true here; we return false for every other catalog function // return true here; we return false for every other catalog function
// so it won't matter what we return here D.C. // so it won't matter what we return here D.C.
if (Driver.logDebug) Driver.debug("isCatalogAtStart not implemented"); if (Driver.logDebug)
Driver.debug("isCatalogAtStart not implemented");
return true; return true;
} }
...@@ -879,7 +942,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -879,7 +942,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{ {
// Give them something to work with here // Give them something to work with here
// everything else returns false so it won't matter what we return here D.C. // everything else returns false so it won't matter what we return here D.C.
if (Driver.logDebug) Driver.debug("getCatalogSeparator not implemented "); if (Driver.logDebug)
Driver.debug("getCatalogSeparator not implemented ");
return "."; return ".";
} }
...@@ -891,7 +955,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -891,7 +955,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsSchemasInDataManipulation() throws SQLException public boolean supportsSchemasInDataManipulation() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsSchemasInDataManipulation false"); if (Driver.logDebug)
Driver.debug("supportsSchemasInDataManipulation false");
return false; return false;
} }
...@@ -903,7 +968,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -903,7 +968,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsSchemasInProcedureCalls() throws SQLException public boolean supportsSchemasInProcedureCalls() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsSchemasInProcedureCalls false"); if (Driver.logDebug)
Driver.debug("supportsSchemasInProcedureCalls false");
return false; return false;
} }
...@@ -917,7 +983,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -917,7 +983,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{ {
boolean schemas = connection.haveMinimumServerVersion("7.3"); boolean schemas = connection.haveMinimumServerVersion("7.3");
if (Driver.logDebug) Driver.debug("supportsSchemasInTableDefinitions " + schemas); if (Driver.logDebug)
Driver.debug("supportsSchemasInTableDefinitions " + schemas);
return schemas; return schemas;
} }
...@@ -929,7 +996,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -929,7 +996,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsSchemasInIndexDefinitions() throws SQLException public boolean supportsSchemasInIndexDefinitions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsSchemasInIndexDefinitions false"); if (Driver.logDebug)
Driver.debug("supportsSchemasInIndexDefinitions false");
return false; return false;
} }
...@@ -941,7 +1009,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -941,7 +1009,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsSchemasInPrivilegeDefinitions false"); if (Driver.logDebug)
Driver.debug("supportsSchemasInPrivilegeDefinitions false");
return false; return false;
} }
...@@ -953,7 +1022,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -953,7 +1022,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsCatalogsInDataManipulation() throws SQLException public boolean supportsCatalogsInDataManipulation() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsCatalogsInDataManipulation false"); if (Driver.logDebug)
Driver.debug("supportsCatalogsInDataManipulation false");
return false; return false;
} }
...@@ -965,7 +1035,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -965,7 +1035,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsCatalogsInProcedureCalls() throws SQLException public boolean supportsCatalogsInProcedureCalls() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsCatalogsInDataManipulation false"); if (Driver.logDebug)
Driver.debug("supportsCatalogsInDataManipulation false");
return false; return false;
} }
...@@ -977,7 +1048,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -977,7 +1048,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsCatalogsInTableDefinitions() throws SQLException public boolean supportsCatalogsInTableDefinitions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsCatalogsInTableDefinitions false"); if (Driver.logDebug)
Driver.debug("supportsCatalogsInTableDefinitions false");
return false; return false;
} }
...@@ -989,7 +1061,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -989,7 +1061,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsCatalogsInIndexDefinitions() throws SQLException public boolean supportsCatalogsInIndexDefinitions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsCatalogsInIndexDefinitions false"); if (Driver.logDebug)
Driver.debug("supportsCatalogsInIndexDefinitions false");
return false; return false;
} }
...@@ -1001,7 +1074,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -1001,7 +1074,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsCatalogsInPrivilegeDefinitions false"); if (Driver.logDebug)
Driver.debug("supportsCatalogsInPrivilegeDefinitions false");
return false; return false;
} }
...@@ -1014,7 +1088,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -1014,7 +1088,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsPositionedDelete() throws SQLException public boolean supportsPositionedDelete() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsPositionedDelete false"); if (Driver.logDebug)
Driver.debug("supportsPositionedDelete false");
return false; // For now... return false; // For now...
} }
...@@ -1026,7 +1101,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -1026,7 +1101,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/ */
public boolean supportsPositionedUpdate() throws SQLException public boolean supportsPositionedUpdate() throws SQLException
{ {
if (Driver.logDebug) Driver.debug("supportsPositionedUpdate false"); if (Driver.logDebug)
Driver.debug("supportsPositionedUpdate false");
return false; // For now... return false; // For now...
} }
...@@ -2184,7 +2260,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -2184,7 +2260,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{ {
byte[][] tuple = new byte[8][0]; byte[][] tuple = new byte[8][0];
tuple[0] = tuple[1] = "".getBytes(); tuple[0] = tuple[1] = "".getBytes();
if (Driver.logDebug) Driver.debug("relname=\"" + r.getString(1) + "\" relacl=\"" + r.getString(2) + "\""); if (Driver.logDebug)
Driver.debug("relname=\"" + r.getString(1) + "\" relacl=\"" + r.getString(2) + "\"");
// For now, don't add to the result as relacl needs to be processed. // For now, don't add to the result as relacl needs to be processed.
//v.addElement(tuple); //v.addElement(tuple);
...@@ -2247,7 +2324,8 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -2247,7 +2324,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{ {
byte[][] tuple = new byte[8][0]; byte[][] tuple = new byte[8][0];
tuple[0] = tuple[1] = "".getBytes(); tuple[0] = tuple[1] = "".getBytes();
if (Driver.logDebug) Driver.debug("relname=\"" + r.getString(1) + "\" relacl=\"" + r.getString(2) + "\""); if (Driver.logDebug)
Driver.debug("relname=\"" + r.getString(1) + "\" relacl=\"" + r.getString(2) + "\"");
// For now, don't add to the result as relacl needs to be processed. // For now, don't add to the result as relacl needs to be processed.
//v.addElement(tuple); //v.addElement(tuple);
...@@ -2385,7 +2463,7 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -2385,7 +2463,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
); );
} }
/* /*
SELECT SELECT
c.relname as primary, c.relname as primary,
c2.relname as foreign, c2.relname as foreign,
...@@ -2399,7 +2477,7 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -2399,7 +2477,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
t.tgnargs,t.tgargs, t.tgnargs,t.tgargs,
p1.proname as updaterule, p1.proname as updaterule,
p2.proname as deleterule p2.proname as deleterule
FROM FROM
pg_trigger t, pg_trigger t,
pg_trigger t1, pg_trigger t1,
pg_class c, pg_class c,
...@@ -2412,7 +2490,7 @@ FROM ...@@ -2412,7 +2490,7 @@ FROM
pg_index ip, pg_index ip,
pg_attribute af, pg_attribute af,
pg_attribute ap pg_attribute ap
WHERE WHERE
(t.tgrelid=c.oid (t.tgrelid=c.oid
AND t.tgisconstraint AND t.tgisconstraint
AND t.tgconstrrelid=c2.oid AND t.tgconstrrelid=c2.oid
...@@ -2440,8 +2518,8 @@ WHERE ...@@ -2440,8 +2518,8 @@ WHERE
and ipc.oid=ap.attrelid and ipc.oid=ap.attrelid
and ip.indisprimary) and ip.indisprimary)
*/ */
/** /**
* *
* @param catalog * @param catalog
* @param schema * @param schema
...@@ -2526,21 +2604,21 @@ WHERE ...@@ -2526,21 +2604,21 @@ WHERE
+ (primaryTable != null ? "frelname" : "prelname") + ",keyseq"); + (primaryTable != null ? "frelname" : "prelname") + ",keyseq");
// returns the following columns // returns the following columns
// and some example data with a table defined as follows // and some example data with a table defined as follows
// create table people ( id int primary key); // create table people ( id int primary key);
// create table policy ( id int primary key); // create table policy ( id int primary key);
// create table users ( id int primary key, people_id int references people(id), policy_id int references policy(id)) // create table users ( id int primary key, people_id int references people(id), policy_id int references policy(id))
// prelname | frelname | tgconstrname | keyseq | fkeyName | tgdeferrable | tginitdeferred // prelname | frelname | tgconstrname | keyseq | fkeyName | tgdeferrable | tginitdeferred
// 1 | 2 | 3 | 4 | 5 | 6 | 7 // 1 | 2 | 3 | 4 | 5 | 6 | 7
// people | users | <unnamed> | 1 | people_pkey | f | f // people | users | <unnamed> | 1 | people_pkey | f | f
// | tgnargs | tgargs | updaterule | deleterule // | tgnargs | tgargs | updaterule | deleterule
// | 8 | 9 | 10 | 11 // | 8 | 9 | 10 | 11
// | 6 | <unnamed>\000users\000people\000UNSPECIFIED\000people_id\000id\000 | RI_FKey_noaction_upd | RI_FKey_noaction_del // | 6 | <unnamed>\000users\000people\000UNSPECIFIED\000people_id\000id\000 | RI_FKey_noaction_upd | RI_FKey_noaction_del
Vector tuples = new Vector(); Vector tuples = new Vector();
...@@ -2596,8 +2674,8 @@ WHERE ...@@ -2596,8 +2674,8 @@ WHERE
// Parse the tgargs data // Parse the tgargs data
String fkeyColumn=""; String fkeyColumn = "";
String pkeyColumn=""; String pkeyColumn = "";
// Note, I am guessing at most of this, but it should be close // Note, I am guessing at most of this, but it should be close
...@@ -2616,8 +2694,9 @@ WHERE ...@@ -2616,8 +2694,9 @@ WHERE
StringTokenizer st = new StringTokenizer(targs, "\\000"); StringTokenizer st = new StringTokenizer(targs, "\\000");
int advance = 4 + (keySequence-1) * 2; int advance = 4 + (keySequence - 1) * 2;
for( int i=0; st.hasMoreTokens() && i < advance ; i++ ) st.nextToken(); // advance to the key column of interest for ( int i = 0; st.hasMoreTokens() && i < advance ; i++ )
st.nextToken(); // advance to the key column of interest
if ( st.hasMoreTokens() ) if ( st.hasMoreTokens() )
{ {
......
...@@ -13,7 +13,7 @@ import org.postgresql.largeobject.*; ...@@ -13,7 +13,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.PGbytea; import org.postgresql.util.PGbytea;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.5 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.6 2002/09/06 21:23:06 momjian 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.AbstractJdbc2ResultSet which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2ResultSet which adds the jdbc2
* methods. The real ResultSet class (for jdbc1) is org.postgresql.jdbc1.Jdbc1ResultSet * methods. The real ResultSet class (for jdbc1) is org.postgresql.jdbc1.Jdbc1ResultSet
...@@ -39,7 +39,7 @@ public abstract class AbstractJdbc1ResultSet ...@@ -39,7 +39,7 @@ public abstract class AbstractJdbc1ResultSet
protected ResultSet next = null; protected ResultSet next = null;
protected StringBuffer sbuf = null; protected StringBuffer sbuf = null;
public byte[][] rowBuffer=null; public byte[][] rowBuffer = null;
public AbstractJdbc1ResultSet(org.postgresql.PGConnection conn, Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) public AbstractJdbc1ResultSet(org.postgresql.PGConnection conn, Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
...@@ -67,8 +67,8 @@ public abstract class AbstractJdbc1ResultSet ...@@ -67,8 +67,8 @@ public abstract class AbstractJdbc1ResultSet
this_row = (byte [][])rows.elementAt(current_row); this_row = (byte [][])rows.elementAt(current_row);
rowBuffer=new byte[this_row.length][]; rowBuffer = new byte[this_row.length][];
System.arraycopy(this_row,0,rowBuffer,0,this_row.length); System.arraycopy(this_row, 0, rowBuffer, 0, this_row.length);
return true; return true;
} }
...@@ -230,12 +230,12 @@ public abstract class AbstractJdbc1ResultSet ...@@ -230,12 +230,12 @@ public abstract class AbstractJdbc1ResultSet
public Time getTime(int columnIndex) throws SQLException public Time getTime(int columnIndex) throws SQLException
{ {
return toTime( getString(columnIndex), (java.sql.ResultSet)this, fields[columnIndex-1].getPGType() ); return toTime( getString(columnIndex), (java.sql.ResultSet)this, fields[columnIndex - 1].getPGType() );
} }
public Timestamp getTimestamp(int columnIndex) throws SQLException public Timestamp getTimestamp(int columnIndex) throws SQLException
{ {
return toTimestamp( getString(columnIndex), (java.sql.ResultSet)this, fields[columnIndex-1].getPGType() ); return toTimestamp( getString(columnIndex), (java.sql.ResultSet)this, fields[columnIndex - 1].getPGType() );
} }
public InputStream getAsciiStream(int columnIndex) throws SQLException public InputStream getAsciiStream(int columnIndex) throws SQLException
...@@ -423,7 +423,8 @@ public abstract class AbstractJdbc1ResultSet ...@@ -423,7 +423,8 @@ public abstract class AbstractJdbc1ResultSet
warnings = null; warnings = null;
} }
public void addWarnings(SQLWarning warnings) { public void addWarnings(SQLWarning warnings)
{
if ( this.warnings != null ) if ( this.warnings != null )
this.warnings.setNextWarning(warnings); this.warnings.setNextWarning(warnings);
else else
...@@ -660,8 +661,10 @@ public abstract class AbstractJdbc1ResultSet ...@@ -660,8 +661,10 @@ public abstract class AbstractJdbc1ResultSet
protected void checkResultSet( int column ) throws SQLException protected void checkResultSet( int column ) throws SQLException
{ {
if ( this_row == null ) throw new PSQLException("postgresql.res.nextrequired"); if ( this_row == null )
if ( column < 1 || column > fields.length ) throw new PSQLException("postgresql.res.colrange" ); throw new PSQLException("postgresql.res.nextrequired");
if ( column < 1 || column > fields.length )
throw new PSQLException("postgresql.res.colrange" );
} }
//----------------- Formatting Methods ------------------- //----------------- Formatting Methods -------------------
...@@ -789,23 +792,31 @@ public abstract class AbstractJdbc1ResultSet ...@@ -789,23 +792,31 @@ public abstract class AbstractJdbc1ResultSet
return null; // SQL NULL return null; // SQL NULL
try try
{ {
if (s.length() == 8) { if (s.length() == 8)
{
//value is a time value //value is a time value
return java.sql.Time.valueOf(s); return java.sql.Time.valueOf(s);
} else if (s.indexOf(".") == 8) { }
else if (s.indexOf(".") == 8)
{
//value is a time value with fractional seconds //value is a time value with fractional seconds
java.sql.Time l_time = java.sql.Time.valueOf(s.substring(0,8)); java.sql.Time l_time = java.sql.Time.valueOf(s.substring(0, 8));
String l_strMillis = s.substring(9); String l_strMillis = s.substring(9);
if (l_strMillis.length() > 3) if (l_strMillis.length() > 3)
l_strMillis = l_strMillis.substring(0,3); l_strMillis = l_strMillis.substring(0, 3);
int l_millis = Integer.parseInt(l_strMillis); int l_millis = Integer.parseInt(l_strMillis);
if (l_millis < 10) { if (l_millis < 10)
{
l_millis = l_millis * 100; l_millis = l_millis * 100;
} else if (l_millis < 100) { }
else if (l_millis < 100)
{
l_millis = l_millis * 10; l_millis = l_millis * 10;
} }
return new java.sql.Time(l_time.getTime() + l_millis); return new java.sql.Time(l_time.getTime() + l_millis);
} else { }
else
{
//value is a timestamp //value is a timestamp
return new java.sql.Time(toTimestamp(s, resultSet, pgDataType).getTime()); return new java.sql.Time(toTimestamp(s, resultSet, pgDataType).getTime());
} }
...@@ -847,12 +858,14 @@ public abstract class AbstractJdbc1ResultSet ...@@ -847,12 +858,14 @@ public abstract class AbstractJdbc1ResultSet
synchronized (rs) synchronized (rs)
{ {
SimpleDateFormat df = null; SimpleDateFormat df = null;
if ( org.postgresql.Driver.logDebug ) org.postgresql.Driver.debug("the data from the DB is "+s); if ( org.postgresql.Driver.logDebug )
org.postgresql.Driver.debug("the data from the DB is " + s);
// If first time, create the buffer, otherwise clear it. // If first time, create the buffer, otherwise clear it.
if (rs.sbuf == null) if (rs.sbuf == null)
rs.sbuf = new StringBuffer(32); rs.sbuf = new StringBuffer(32);
else { else
{
rs.sbuf.setLength(0); rs.sbuf.setLength(0);
} }
...@@ -880,7 +893,8 @@ public abstract class AbstractJdbc1ResultSet ...@@ -880,7 +893,8 @@ public abstract class AbstractJdbc1ResultSet
if (i < 24) if (i < 24)
rs.sbuf.append(c); rs.sbuf.append(c);
c = s.charAt(i++); c = s.charAt(i++);
} while (i < slen && Character.isDigit(c)); }
while (i < slen && Character.isDigit(c));
// If there wasn't at least 3 digits we should add some zeros // If there wasn't at least 3 digits we should add some zeros
// to make up the 3 digits we tell java to expect. // to make up the 3 digits we tell java to expect.
...@@ -913,10 +927,13 @@ public abstract class AbstractJdbc1ResultSet ...@@ -913,10 +927,13 @@ public abstract class AbstractJdbc1ResultSet
{ {
// Just found fractional seconds but no timezone. // Just found fractional seconds but no timezone.
//If timestamptz then we use GMT, else local timezone //If timestamptz then we use GMT, else local timezone
if (pgDataType.equals("timestamptz")) { if (pgDataType.equals("timestamptz"))
{
rs.sbuf.append(" GMT"); rs.sbuf.append(" GMT");
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z"); df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
} else { }
else
{
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
} }
} }
...@@ -925,10 +942,13 @@ public abstract class AbstractJdbc1ResultSet ...@@ -925,10 +942,13 @@ public abstract class AbstractJdbc1ResultSet
{ {
// No tz or fractional second info. // No tz or fractional second info.
//If timestamptz then we use GMT, else local timezone //If timestamptz then we use GMT, else local timezone
if (pgDataType.equals("timestamptz")) { if (pgDataType.equals("timestamptz"))
{
rs.sbuf.append(" GMT"); rs.sbuf.append(" GMT");
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
} else { }
else
{
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
} }
} }
...@@ -952,7 +972,8 @@ public abstract class AbstractJdbc1ResultSet ...@@ -952,7 +972,8 @@ public abstract class AbstractJdbc1ResultSet
try try
{ {
// All that's left is to parse the string and return the ts. // All that's left is to parse the string and return the ts.
if ( org.postgresql.Driver.logDebug ) org.postgresql.Driver.debug( "" + df.parse(rs.sbuf.toString()).getTime() ); if ( org.postgresql.Driver.logDebug )
org.postgresql.Driver.debug( "" + df.parse(rs.sbuf.toString()).getTime() );
return new Timestamp(df.parse(rs.sbuf.toString()).getTime()); return new Timestamp(df.parse(rs.sbuf.toString()).getTime());
} }
......
...@@ -8,7 +8,7 @@ import java.util.Vector; ...@@ -8,7 +8,7 @@ import java.util.Vector;
import org.postgresql.largeobject.*; import org.postgresql.largeobject.*;
import org.postgresql.util.*; import org.postgresql.util.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.6 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.7 2002/09/06 21:23:06 momjian 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
...@@ -79,12 +79,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -79,12 +79,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
parseSqlStmt(p_sql); // this allows Callable stmt to override parseSqlStmt(p_sql); // this allows Callable stmt to override
} }
protected void parseSqlStmt (String p_sql) throws SQLException { protected void parseSqlStmt (String p_sql) throws SQLException
{
String l_sql = p_sql; String l_sql = p_sql;
l_sql = replaceProcessing(l_sql); l_sql = replaceProcessing(l_sql);
if (this instanceof CallableStatement) { if (this instanceof CallableStatement)
{
l_sql = modifyJdbcCall(l_sql); l_sql = modifyJdbcCall(l_sql);
} }
...@@ -213,7 +215,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -213,7 +215,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{ {
if (isFunction && !returnTypeSet) if (isFunction && !returnTypeSet)
throw new PSQLException("postgresql.call.noreturntype"); throw new PSQLException("postgresql.call.noreturntype");
if (isFunction) { // set entry 1 to dummy entry.. if (isFunction)
{ // set entry 1 to dummy entry..
m_binds[0] = ""; // dummy entry which ensured that no one overrode m_binds[0] = ""; // dummy entry which ensured that no one overrode
m_bindTypes[0] = PG_TEXT; m_bindTypes[0] = PG_TEXT;
// and calls to setXXX (2,..) really went to first arg in a function call.. // and calls to setXXX (2,..) really went to first arg in a function call..
...@@ -222,6 +225,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -222,6 +225,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
// New in 7.1, if we have a previous resultset then force it to close // New in 7.1, if we have a previous resultset then force it to close
// This brings us nearer to compliance, and helps memory management. // This brings us nearer to compliance, and helps memory management.
// Internal stuff will call ExecSQL directly, bypassing this. // Internal stuff will call ExecSQL directly, bypassing this.
if (result != null) if (result != null)
{ {
java.sql.ResultSet rs = getResultSet(); java.sql.ResultSet rs = getResultSet();
...@@ -230,27 +234,34 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -230,27 +234,34 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
} }
//Use server prepared statements if directed //Use server prepared statements if directed
if (m_useServerPrepare) { if (m_useServerPrepare)
if (m_statementName == null) { {
if (m_statementName == null)
{
m_statementName = "JDBC_STATEMENT_" + m_preparedCount++; m_statementName = "JDBC_STATEMENT_" + m_preparedCount++;
m_origSqlFragments = new String[m_sqlFragments.length]; m_origSqlFragments = new String[m_sqlFragments.length];
m_executeSqlFragments = new String[m_sqlFragments.length]; m_executeSqlFragments = new String[m_sqlFragments.length];
System.arraycopy(m_sqlFragments, 0, m_origSqlFragments, 0, m_sqlFragments.length); System.arraycopy(m_sqlFragments, 0, m_origSqlFragments, 0, m_sqlFragments.length);
m_executeSqlFragments[0] = "EXECUTE " + m_statementName; m_executeSqlFragments[0] = "EXECUTE " + m_statementName;
if (m_sqlFragments.length > 1) { if (m_sqlFragments.length > 1)
{
m_executeSqlFragments[0] = m_executeSqlFragments[0] + "("; m_executeSqlFragments[0] = m_executeSqlFragments[0] + "(";
for(int i = 1; i < m_bindTypes.length; i++) { for (int i = 1; i < m_bindTypes.length; i++)
{
m_executeSqlFragments[i] = ", "; m_executeSqlFragments[i] = ", ";
} }
m_executeSqlFragments[m_bindTypes.length] = ")"; m_executeSqlFragments[m_bindTypes.length] = ")";
} }
synchronized (sbuf) { synchronized (sbuf)
{
sbuf.setLength(0); sbuf.setLength(0);
sbuf.append("PREPARE "); sbuf.append("PREPARE ");
sbuf.append(m_statementName); sbuf.append(m_statementName);
if (m_origSqlFragments.length > 1) { if (m_origSqlFragments.length > 1)
{
sbuf.append("("); sbuf.append("(");
for(int i = 0; i < m_bindTypes.length - 1; i++) { for (int i = 0; i < m_bindTypes.length - 1; i++)
{
sbuf.append(m_bindTypes[i]); sbuf.append(m_bindTypes[i]);
sbuf.append(", "); sbuf.append(", ");
} }
...@@ -259,7 +270,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -259,7 +270,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
} }
sbuf.append(" AS "); sbuf.append(" AS ");
sbuf.append(m_origSqlFragments[0]); sbuf.append(m_origSqlFragments[0]);
for(int i = 1; i < m_origSqlFragments.length; i++) { for (int i = 1; i < m_origSqlFragments.length; i++)
{
sbuf.append(" $"); sbuf.append(" $");
sbuf.append(i); sbuf.append(i);
sbuf.append(" "); sbuf.append(" ");
...@@ -272,7 +284,9 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -272,7 +284,9 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
System.arraycopy(m_executeSqlFragments, 1, m_sqlFragments, 1, m_sqlFragments.length - 1); System.arraycopy(m_executeSqlFragments, 1, m_sqlFragments, 1, m_sqlFragments.length - 1);
} }
} else { }
else
{
m_sqlFragments = m_executeSqlFragments; m_sqlFragments = m_executeSqlFragments;
} }
} }
...@@ -281,7 +295,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -281,7 +295,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
result = ((AbstractJdbc1Connection)connection).ExecSQL(m_sqlFragments, m_binds, (java.sql.Statement)this); result = ((AbstractJdbc1Connection)connection).ExecSQL(m_sqlFragments, m_binds, (java.sql.Statement)this);
//If we are executing a callable statement function set the return data //If we are executing a callable statement function set the return data
if (isFunction) { if (isFunction)
{
if (!((AbstractJdbc1ResultSet)result).reallyResultSet()) if (!((AbstractJdbc1ResultSet)result).reallyResultSet())
throw new PSQLException("postgresql.call.noreturnval"); throw new PSQLException("postgresql.call.noreturnval");
if (!result.next ()) if (!result.next ())
...@@ -291,10 +306,12 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -291,10 +306,12 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
if (columnType != functionReturnType) if (columnType != functionReturnType)
throw new PSQLException ("postgresql.call.wrongrtntype", throw new PSQLException ("postgresql.call.wrongrtntype",
new Object[]{ new Object[]{
"java.sql.Types=" + columnType, "java.sql.Types="+functionReturnType }); "java.sql.Types=" + columnType, "java.sql.Types=" + functionReturnType });
result.close (); result.close ();
return true; return true;
} else { }
else
{
return (result != null && ((AbstractJdbc1ResultSet)result).reallyResultSet()); return (result != null && ((AbstractJdbc1ResultSet)result).reallyResultSet());
} }
} }
...@@ -565,7 +582,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -565,7 +582,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
*/ */
protected String replaceProcessing(String p_sql) protected String replaceProcessing(String p_sql)
{ {
if (replaceProcessingEnabled) { if (replaceProcessingEnabled)
{
// Since escape codes can only appear in SQL CODE, we keep track // Since escape codes can only appear in SQL CODE, we keep track
// of if we enter a string or not. // of if we enter a string or not.
StringBuffer newsql = new StringBuffer(p_sql.length()); StringBuffer newsql = new StringBuffer(p_sql.length());
...@@ -626,7 +644,9 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -626,7 +644,9 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
} }
return newsql.toString(); return newsql.toString();
} else { }
else
{
return p_sql; return p_sql;
} }
} }
...@@ -716,7 +736,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -716,7 +736,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed //Note this should be fixed
//as soon as the backend correctly supports int8 type //as soon as the backend correctly supports int8 type
//comparisons //comparisons
bind(parameterIndex,"'" + Integer.toString(x) +"'", PG_INT2); bind(parameterIndex, "'" + Integer.toString(x) + "'", PG_INT2);
} }
/* /*
...@@ -745,7 +765,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -745,7 +765,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed //Note this should be fixed
//as soon as the backend correctly supports int8 type //as soon as the backend correctly supports int8 type
//comparisons //comparisons
bind(parameterIndex, "'"+Long.toString(x)+"'", PG_INT8); bind(parameterIndex, "'" + Long.toString(x) + "'", PG_INT8);
} }
/* /*
...@@ -761,7 +781,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -761,7 +781,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed //Note this should be fixed
//as soon as the backend correctly supports int8 type //as soon as the backend correctly supports int8 type
//comparisons //comparisons
bind(parameterIndex, "'"+Float.toString(x)+"'", PG_FLOAT); bind(parameterIndex, "'" + Float.toString(x) + "'", PG_FLOAT);
} }
/* /*
...@@ -777,7 +797,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -777,7 +797,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed //Note this should be fixed
//as soon as the backend correctly supports int8 type //as soon as the backend correctly supports int8 type
//comparisons //comparisons
bind(parameterIndex, "'"+Double.toString(x)+"'", PG_DOUBLE); bind(parameterIndex, "'" + Double.toString(x) + "'", PG_DOUBLE);
} }
/* /*
...@@ -798,7 +818,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -798,7 +818,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed //Note this should be fixed
//as soon as the backend correctly supports int8 type //as soon as the backend correctly supports int8 type
//comparisons //comparisons
bind(parameterIndex, "'"+x.toString()+"'", PG_NUMERIC); bind(parameterIndex, "'" + x.toString() + "'", PG_NUMERIC);
} }
} }
...@@ -959,52 +979,69 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -959,52 +979,69 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
sbuf.append(l_year); sbuf.append(l_year);
sbuf.append('-'); sbuf.append('-');
int l_month = x.getMonth() + 1; int l_month = x.getMonth() + 1;
if (l_month < 10) sbuf.append('0'); if (l_month < 10)
sbuf.append('0');
sbuf.append(l_month); sbuf.append(l_month);
sbuf.append('-'); sbuf.append('-');
int l_day = x.getDate(); int l_day = x.getDate();
if (l_day < 10) sbuf.append('0'); if (l_day < 10)
sbuf.append('0');
sbuf.append(l_day); sbuf.append(l_day);
sbuf.append(' '); sbuf.append(' ');
int l_hours = x.getHours(); int l_hours = x.getHours();
if (l_hours < 10) sbuf.append('0'); if (l_hours < 10)
sbuf.append('0');
sbuf.append(l_hours); sbuf.append(l_hours);
sbuf.append(':'); sbuf.append(':');
int l_minutes = x.getMinutes(); int l_minutes = x.getMinutes();
if (l_minutes < 10) sbuf.append('0'); if (l_minutes < 10)
sbuf.append('0');
sbuf.append(l_minutes); sbuf.append(l_minutes);
sbuf.append(':'); sbuf.append(':');
int l_seconds = x.getSeconds(); int l_seconds = x.getSeconds();
if (l_seconds < 10) sbuf.append('0'); if (l_seconds < 10)
sbuf.append('0');
sbuf.append(l_seconds); sbuf.append(l_seconds);
// Make decimal from nanos. // Make decimal from nanos.
char[] l_decimal = {'0','0','0','0','0','0','0','0','0'}; char[] l_decimal = {'0', '0', '0', '0', '0', '0', '0', '0', '0'};
char[] l_nanos = Integer.toString(x.getNanos()).toCharArray(); char[] l_nanos = Integer.toString(x.getNanos()).toCharArray();
System.arraycopy(l_nanos, 0, l_decimal, l_decimal.length - l_nanos.length, l_nanos.length); System.arraycopy(l_nanos, 0, l_decimal, l_decimal.length - l_nanos.length, l_nanos.length);
sbuf.append('.'); sbuf.append('.');
if (connection.haveMinimumServerVersion("7.2")) { if (connection.haveMinimumServerVersion("7.2"))
sbuf.append(l_decimal,0,6); {
} else { sbuf.append(l_decimal, 0, 6);
}
else
{
// Because 7.1 include bug that "hh:mm:59.999" becomes "hh:mm:60.00". // Because 7.1 include bug that "hh:mm:59.999" becomes "hh:mm:60.00".
sbuf.append(l_decimal,0,2); sbuf.append(l_decimal, 0, 2);
} }
//add timezone offset //add timezone offset
int l_offset = -(x.getTimezoneOffset()); int l_offset = -(x.getTimezoneOffset());
int l_houros = l_offset/60; int l_houros = l_offset / 60;
if (l_houros >= 0) { if (l_houros >= 0)
{
sbuf.append('+'); sbuf.append('+');
} else { }
else
{
sbuf.append('-'); sbuf.append('-');
} }
if (l_houros > -10 && l_houros < 10) sbuf.append('0'); if (l_houros > -10 && l_houros < 10)
if (l_houros >= 0) { sbuf.append('0');
if (l_houros >= 0)
{
sbuf.append(l_houros); sbuf.append(l_houros);
} else {
sbuf.append(-l_houros);
} }
int l_minos = l_offset - (l_houros *60); else
if (l_minos != 0) { {
if (l_minos < 10) sbuf.append('0'); sbuf.append( -l_houros);
}
int l_minos = l_offset - (l_houros * 60);
if (l_minos != 0)
{
if (l_minos < 10)
sbuf.append('0');
sbuf.append(l_minos); sbuf.append(l_minos);
} }
sbuf.append("'"); sbuf.append("'");
...@@ -1206,7 +1243,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1206,7 +1243,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{ {
int i; int i;
for (i = 0 ; i < m_binds.length ; i++) { for (i = 0 ; i < m_binds.length ; i++)
{
m_binds[i] = null; m_binds[i] = null;
m_bindTypes[i] = null; m_bindTypes[i] = null;
} }
...@@ -1236,7 +1274,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1236,7 +1274,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
if (x == null) if (x == null)
{ {
setNull(parameterIndex, Types.OTHER); setNull(parameterIndex, Types.OTHER);
return; return ;
} }
switch (targetSqlType) switch (targetSqlType)
{ {
...@@ -1257,7 +1295,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1257,7 +1295,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed //Note this should be fixed
//as soon as the backend correctly supports int8 type //as soon as the backend correctly supports int8 type
//comparisons //comparisons
bind(parameterIndex, "'"+x.toString()+"'", PG_NUMERIC); bind(parameterIndex, "'" + x.toString() + "'", PG_NUMERIC);
break; break;
case Types.CHAR: case Types.CHAR:
case Types.VARCHAR: case Types.VARCHAR:
...@@ -1311,7 +1349,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1311,7 +1349,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
if (x == null) if (x == null)
{ {
setNull(parameterIndex, Types.OTHER); setNull(parameterIndex, Types.OTHER);
return; return ;
} }
if (x instanceof String) if (x instanceof String)
setString(parameterIndex, (String)x); setString(parameterIndex, (String)x);
...@@ -1440,7 +1478,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1440,7 +1478,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public boolean getBoolean(int parameterIndex) throws SQLException public boolean getBoolean(int parameterIndex) throws SQLException
{ {
checkIndex (parameterIndex, Types.BIT, "Boolean"); checkIndex (parameterIndex, Types.BIT, "Boolean");
if (callResult == null) return false; if (callResult == null)
return false;
return ((Boolean)callResult).booleanValue (); return ((Boolean)callResult).booleanValue ();
} }
...@@ -1454,7 +1493,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1454,7 +1493,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public byte getByte(int parameterIndex) throws SQLException public byte getByte(int parameterIndex) throws SQLException
{ {
checkIndex (parameterIndex, Types.TINYINT, "Byte"); checkIndex (parameterIndex, Types.TINYINT, "Byte");
if (callResult == null) return 0; if (callResult == null)
return 0;
return (byte)((Integer)callResult).intValue (); return (byte)((Integer)callResult).intValue ();
} }
...@@ -1468,7 +1508,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1468,7 +1508,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public short getShort(int parameterIndex) throws SQLException public short getShort(int parameterIndex) throws SQLException
{ {
checkIndex (parameterIndex, Types.SMALLINT, "Short"); checkIndex (parameterIndex, Types.SMALLINT, "Short");
if (callResult == null) return 0; if (callResult == null)
return 0;
return (short)((Integer)callResult).intValue (); return (short)((Integer)callResult).intValue ();
} }
...@@ -1483,7 +1524,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1483,7 +1524,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public int getInt(int parameterIndex) throws SQLException public int getInt(int parameterIndex) throws SQLException
{ {
checkIndex (parameterIndex, Types.INTEGER, "Int"); checkIndex (parameterIndex, Types.INTEGER, "Int");
if (callResult == null) return 0; if (callResult == null)
return 0;
return ((Integer)callResult).intValue (); return ((Integer)callResult).intValue ();
} }
...@@ -1497,7 +1539,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1497,7 +1539,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public long getLong(int parameterIndex) throws SQLException public long getLong(int parameterIndex) throws SQLException
{ {
checkIndex (parameterIndex, Types.BIGINT, "Long"); checkIndex (parameterIndex, Types.BIGINT, "Long");
if (callResult == null) return 0; if (callResult == null)
return 0;
return ((Long)callResult).longValue (); return ((Long)callResult).longValue ();
} }
...@@ -1511,7 +1554,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1511,7 +1554,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public float getFloat(int parameterIndex) throws SQLException public float getFloat(int parameterIndex) throws SQLException
{ {
checkIndex (parameterIndex, Types.REAL, "Float"); checkIndex (parameterIndex, Types.REAL, "Float");
if (callResult == null) return 0; if (callResult == null)
return 0;
return ((Float)callResult).floatValue (); return ((Float)callResult).floatValue ();
} }
...@@ -1525,7 +1569,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1525,7 +1569,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public double getDouble(int parameterIndex) throws SQLException public double getDouble(int parameterIndex) throws SQLException
{ {
checkIndex (parameterIndex, Types.DOUBLE, "Double"); checkIndex (parameterIndex, Types.DOUBLE, "Double");
if (callResult == null) return 0; if (callResult == null)
return 0;
return ((Double)callResult).doubleValue (); return ((Double)callResult).doubleValue ();
} }
...@@ -1701,20 +1746,25 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1701,20 +1746,25 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
* select <some_function> (?, [?, ...]) as result * select <some_function> (?, [?, ...]) as result
* *
*/ */
private String modifyJdbcCall(String p_sql) throws SQLException { private String modifyJdbcCall(String p_sql) throws SQLException
{
// syntax checking is not complete only a few basics :( // syntax checking is not complete only a few basics :(
originalSql = p_sql; // save for error msgs.. originalSql = p_sql; // save for error msgs..
String l_sql = p_sql; String l_sql = p_sql;
int index = l_sql.indexOf ("="); // is implied func or proc? int index = l_sql.indexOf ("="); // is implied func or proc?
boolean isValid = true; boolean isValid = true;
if (index != -1) { if (index != -1)
{
isFunction = true; isFunction = true;
isValid = l_sql.indexOf ("?") < index; // ? before = isValid = l_sql.indexOf ("?") < index; // ? before =
} }
l_sql = l_sql.trim (); l_sql = l_sql.trim ();
if (l_sql.startsWith ("{") && l_sql.endsWith ("}")) { if (l_sql.startsWith ("{") && l_sql.endsWith ("}"))
l_sql = l_sql.substring (1, l_sql.length() -1); {
} else isValid = false; l_sql = l_sql.substring (1, l_sql.length() - 1);
}
else
isValid = false;
index = l_sql.indexOf ("call"); index = l_sql.indexOf ("call");
if (index == -1 || !isValid) if (index == -1 || !isValid)
throw new PSQLException ("postgresql.call.malformed", throw new PSQLException ("postgresql.call.malformed",
...@@ -1739,19 +1789,21 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1739,19 +1789,21 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
/** helperfunction for the getXXX calls to check isFunction and index == 1 /** helperfunction for the getXXX calls to check isFunction and index == 1
*/ */
protected void checkIndex (int parameterIndex, int type, String getName) protected void checkIndex (int parameterIndex, int type, String getName)
throws SQLException { throws SQLException
{
checkIndex (parameterIndex); checkIndex (parameterIndex);
if (type != this.testReturn) if (type != this.testReturn)
throw new PSQLException("postgresql.call.wrongget", throw new PSQLException("postgresql.call.wrongget",
new Object[]{"java.sql.Types="+testReturn, new Object[]{"java.sql.Types=" + testReturn,
getName, getName,
"java.sql.Types="+type}); "java.sql.Types=" + type});
} }
/** helperfunction for the getXXX calls to check isFunction and index == 1 /** helperfunction for the getXXX calls to check isFunction and index == 1
* @param parameterIndex index of getXXX (index) * @param parameterIndex index of getXXX (index)
* check to make sure is a function and index == 1 * check to make sure is a function and index == 1
*/ */
private void checkIndex (int parameterIndex) throws SQLException { private void checkIndex (int parameterIndex) throws SQLException
{
if (!isFunction) if (!isFunction)
throw new PSQLException("postgresql.call.noreturntype"); throw new PSQLException("postgresql.call.noreturntype");
if (parameterIndex != 1) if (parameterIndex != 1)
...@@ -1760,11 +1812,13 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1760,11 +1812,13 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public void setUseServerPrepare(boolean flag) { public void setUseServerPrepare(boolean flag)
{
m_useServerPrepare = flag; m_useServerPrepare = flag;
} }
public boolean isUseServerPrepare() { public boolean isUseServerPrepare()
{
return m_useServerPrepare; return m_useServerPrepare;
} }
......
...@@ -6,7 +6,7 @@ import java.sql.*; ...@@ -6,7 +6,7 @@ import java.sql.*;
import org.postgresql.Field; import org.postgresql.Field;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.4 2002/07/26 05:29:35 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.5 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.Connection interface for JDBC1. * This class implements the java.sql.Connection interface for JDBC1.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1Connection * org.postgresql.jdbc1.AbstractJdbc1Connection
......
...@@ -5,7 +5,7 @@ import java.sql.*; ...@@ -5,7 +5,7 @@ import java.sql.*;
import java.util.Vector; import java.util.Vector;
import org.postgresql.Field; import org.postgresql.Field;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.3 2002/07/26 05:29:35 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.4 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.ResultSet interface for JDBC1. * This class implements the java.sql.ResultSet interface for JDBC1.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1ResultSet * org.postgresql.jdbc1.AbstractJdbc1ResultSet
......
...@@ -3,7 +3,7 @@ package org.postgresql.jdbc1; ...@@ -3,7 +3,7 @@ package org.postgresql.jdbc1;
import java.sql.*; import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.2 2002/07/24 22:08:40 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.3 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.Statement interface for JDBC1. * This class implements the java.sql.Statement interface for JDBC1.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1Statement * org.postgresql.jdbc1.AbstractJdbc1Statement
......
...@@ -6,7 +6,7 @@ import java.net.ConnectException; ...@@ -6,7 +6,7 @@ import java.net.ConnectException;
import java.sql.*; import java.sql.*;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.1 2002/07/23 03:59:55 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.2 2002/09/06 21:23:06 momjian 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.AbstractJdbc1Connection which provides the jdbc1 * org.postgresql.jdbc1.AbstractJdbc1Connection which provides the jdbc1
* methods. The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection * methods. The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection
...@@ -55,34 +55,44 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr ...@@ -55,34 +55,44 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
public void cancelQuery() throws SQLException public void cancelQuery() throws SQLException
{ {
org.postgresql.PG_Stream cancelStream = null; org.postgresql.PG_Stream cancelStream = null;
try { try
{
cancelStream = new org.postgresql.PG_Stream(PG_HOST, PG_PORT); cancelStream = new org.postgresql.PG_Stream(PG_HOST, PG_PORT);
} catch (ConnectException cex) { }
catch (ConnectException cex)
{
// Added by Peter Mount <peter@retep.org.uk> // Added by Peter Mount <peter@retep.org.uk>
// ConnectException is thrown when the connection cannot be made. // ConnectException is thrown when the connection cannot be made.
// we trap this an return a more meaningful message for the end user // we trap this an return a more meaningful message for the end user
throw new PSQLException ("postgresql.con.refused"); throw new PSQLException ("postgresql.con.refused");
} catch (IOException e) { }
throw new PSQLException ("postgresql.con.failed",e); catch (IOException e)
{
throw new PSQLException ("postgresql.con.failed", e);
} }
// Now we need to construct and send a cancel packet // Now we need to construct and send a cancel packet
try { try
{
cancelStream.SendInteger(16, 4); cancelStream.SendInteger(16, 4);
cancelStream.SendInteger(80877102, 4); cancelStream.SendInteger(80877102, 4);
cancelStream.SendInteger(pid, 4); cancelStream.SendInteger(pid, 4);
cancelStream.SendInteger(ckey, 4); cancelStream.SendInteger(ckey, 4);
cancelStream.flush(); cancelStream.flush();
} }
catch(IOException e) { catch (IOException e)
throw new PSQLException("postgresql.con.failed",e); {
throw new PSQLException("postgresql.con.failed", e);
} }
finally { finally
try { {
if(cancelStream != null) try
{
if (cancelStream != null)
cancelStream.close(); cancelStream.close();
} }
catch(IOException e) {} // Ignore catch (IOException e)
{} // Ignore
} }
} }
...@@ -111,8 +121,10 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr ...@@ -111,8 +121,10 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
//Because the get/setLogStream methods are deprecated in JDBC2 //Because the get/setLogStream methods are deprecated in JDBC2
//we use the get/setLogWriter methods here for JDBC2 by overriding //we use the get/setLogWriter methods here for JDBC2 by overriding
//the base version of this method //the base version of this method
protected void enableDriverManagerLogging() { protected void enableDriverManagerLogging()
if (DriverManager.getLogWriter() == null) { {
if (DriverManager.getLogWriter() == null)
{
DriverManager.setLogWriter(new PrintWriter(System.out)); DriverManager.setLogWriter(new PrintWriter(System.out));
} }
} }
......
...@@ -15,12 +15,13 @@ import org.postgresql.util.PGbytea; ...@@ -15,12 +15,13 @@ import org.postgresql.util.PGbytea;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.6 2002/09/01 23:40:36 davec Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.7 2002/09/06 21:23:06 momjian 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.AbstractJdbc1ResultSet which provides the jdbc1 * org.postgresql.jdbc1.AbstractJdbc1ResultSet which provides the jdbc1
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2ResultSet * methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2ResultSet
*/ */
public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet { public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet
{
//needed for updateable result set support //needed for updateable result set support
protected boolean updateable = false; protected boolean updateable = false;
...@@ -39,16 +40,19 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -39,16 +40,19 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public AbstractJdbc2ResultSet(org.postgresql.PGConnection conn, Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) { public AbstractJdbc2ResultSet(org.postgresql.PGConnection conn, Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super (conn, statement, fields, tuples, status, updateCount, insertOID, binaryCursor); super (conn, statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
} }
public java.net.URL getURL(int columnIndex) throws SQLException { public java.net.URL getURL(int columnIndex) throws SQLException
{
return null; return null;
} }
public java.net.URL getURL(String columnName) throws SQLException { public java.net.URL getURL(String columnName) throws SQLException
{
return null; return null;
} }
...@@ -68,7 +72,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -68,7 +72,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
* @return a Object holding the column value * @return a Object holding the column value
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
*/ */
public Object getObject(int columnIndex) throws SQLException { public Object getObject(int columnIndex) throws SQLException
{
Field field; Field field;
checkResultSet( columnIndex ); checkResultSet( columnIndex );
...@@ -80,12 +85,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -80,12 +85,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
field = fields[columnIndex - 1]; field = fields[columnIndex - 1];
// some fields can be null, mainly from those returned by MetaData methods // some fields can be null, mainly from those returned by MetaData methods
if (field == null) { if (field == null)
{
wasNullFlag = true; wasNullFlag = true;
return null; return null;
} }
switch (field.getSQLType()) { switch (field.getSQLType())
{
case Types.BIT: case Types.BIT:
return getBoolean(columnIndex) ? Boolean.TRUE : Boolean.FALSE; return getBoolean(columnIndex) ? Boolean.TRUE : Boolean.FALSE;
...@@ -131,17 +138,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -131,17 +138,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
default: default:
String type = field.getPGType(); String type = field.getPGType();
// if the backend doesn't know the type then coerce to String // if the backend doesn't know the type then coerce to String
if (type.equals("unknown")) { if (type.equals("unknown"))
{
return getString(columnIndex); return getString(columnIndex);
} }
else { else
{
return connection.getObject(field.getPGType(), getString(columnIndex)); return connection.getObject(field.getPGType(), getString(columnIndex));
} }
} }
} }
public boolean absolute(int index) throws SQLException { public boolean absolute(int index) throws SQLException
{
// index is 1-based, but internally we use 0-based indices // index is 1-based, but internally we use 0-based indices
int internalIndex; int internalIndex;
...@@ -152,21 +162,25 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -152,21 +162,25 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
//if index<0, count from the end of the result set, but check //if index<0, count from the end of the result set, but check
//to be sure that it is not beyond the first index //to be sure that it is not beyond the first index
if (index < 0) { if (index < 0)
{
if (index >= -rows_size) if (index >= -rows_size)
internalIndex = rows_size + index; internalIndex = rows_size + index;
else { else
{
beforeFirst(); beforeFirst();
return false; return false;
} }
} }
else { else
{
//must be the case that index>0, //must be the case that index>0,
//find the correct place, assuming that //find the correct place, assuming that
//the index is not too large //the index is not too large
if (index <= rows_size) if (index <= rows_size)
internalIndex = index - 1; internalIndex = index - 1;
else { else
{
afterLast(); afterLast();
return false; return false;
} }
...@@ -178,14 +192,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -178,14 +192,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public void afterLast() throws SQLException { public void afterLast() throws SQLException
{
final int rows_size = rows.size(); final int rows_size = rows.size();
if (rows_size > 0) if (rows_size > 0)
current_row = rows_size; current_row = rows_size;
} }
public void beforeFirst() throws SQLException { public void beforeFirst() throws SQLException
{
if (rows.size() > 0) if (rows.size() > 0)
current_row = -1; current_row = -1;
} }
...@@ -207,12 +223,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -207,12 +223,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public java.sql.Array getArray(String colName) throws SQLException { public java.sql.Array getArray(String colName) throws SQLException
{
return getArray(findColumn(colName)); return getArray(findColumn(colName));
} }
public java.sql.Array getArray(int i) throws SQLException { public java.sql.Array getArray(int i) throws SQLException
{
wasNullFlag = (this_row[i - 1] == null); wasNullFlag = (this_row[i - 1] == null);
if (wasNullFlag) if (wasNullFlag)
return null; return null;
...@@ -223,17 +241,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -223,17 +241,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException { public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException
{
return getBigDecimal(columnIndex, -1); return getBigDecimal(columnIndex, -1);
} }
public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException { public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException
{
return getBigDecimal(findColumn(columnName)); return getBigDecimal(findColumn(columnName));
} }
public Blob getBlob(String columnName) throws SQLException { public Blob getBlob(String columnName) throws SQLException
{
return getBlob(findColumn(columnName)); return getBlob(findColumn(columnName));
} }
...@@ -241,18 +262,21 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -241,18 +262,21 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public abstract Blob getBlob(int i) throws SQLException; public abstract Blob getBlob(int i) throws SQLException;
public java.io.Reader getCharacterStream(String columnName) throws SQLException { public java.io.Reader getCharacterStream(String columnName) throws SQLException
{
return getCharacterStream(findColumn(columnName)); return getCharacterStream(findColumn(columnName));
} }
public java.io.Reader getCharacterStream(int i) throws SQLException { public java.io.Reader getCharacterStream(int i) throws SQLException
{
checkResultSet( i ); checkResultSet( i );
wasNullFlag = (this_row[i - 1] == null); wasNullFlag = (this_row[i - 1] == null);
if (wasNullFlag) if (wasNullFlag)
return null; return null;
if (((AbstractJdbc2Connection) connection).haveMinimumCompatibleVersion("7.2")) { if (((AbstractJdbc2Connection) connection).haveMinimumCompatibleVersion("7.2"))
{
//Version 7.2 supports AsciiStream for all the PG text types //Version 7.2 supports AsciiStream for all the PG text types
//As the spec/javadoc for this method indicate this is to be used for //As the spec/javadoc for this method indicate this is to be used for
//large text values (i.e. LONGVARCHAR) PG doesn't have a separate //large text values (i.e. LONGVARCHAR) PG doesn't have a separate
...@@ -261,7 +285,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -261,7 +285,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
//getString() since there is no current way to stream the value from the server //getString() since there is no current way to stream the value from the server
return new CharArrayReader(getString(i).toCharArray()); return new CharArrayReader(getString(i).toCharArray());
} }
else { else
{
// In 7.1 Handle as BLOBS so return the LargeObject input stream // In 7.1 Handle as BLOBS so return the LargeObject input stream
Encoding encoding = connection.getEncoding(); Encoding encoding = connection.getEncoding();
InputStream input = getBinaryStream(i); InputStream input = getBinaryStream(i);
...@@ -270,7 +295,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -270,7 +295,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public Clob getClob(String columnName) throws SQLException { public Clob getClob(String columnName) throws SQLException
{
return getClob(findColumn(columnName)); return getClob(findColumn(columnName));
} }
...@@ -278,14 +304,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -278,14 +304,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public abstract Clob getClob(int i) throws SQLException; public abstract Clob getClob(int i) throws SQLException;
public int getConcurrency() throws SQLException { public int getConcurrency() throws SQLException
{
if (statement == null) if (statement == null)
return java.sql.ResultSet.CONCUR_READ_ONLY; return java.sql.ResultSet.CONCUR_READ_ONLY;
return statement.getResultSetConcurrency(); return statement.getResultSetConcurrency();
} }
public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException { public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException
{
// If I read the specs, this should use cal only if we don't // If I read the specs, this should use cal only if we don't
// store the timezone, and if we do, then act just like getDate()? // store the timezone, and if we do, then act just like getDate()?
// for now... // for now...
...@@ -293,7 +321,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -293,7 +321,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public Time getTime(int i, java.util.Calendar cal) throws SQLException { public Time getTime(int i, java.util.Calendar cal) throws SQLException
{
// If I read the specs, this should use cal only if we don't // If I read the specs, this should use cal only if we don't
// store the timezone, and if we do, then act just like getTime()? // store the timezone, and if we do, then act just like getTime()?
// for now... // for now...
...@@ -301,7 +330,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -301,7 +330,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public Timestamp getTimestamp(int i, java.util.Calendar cal) throws SQLException { public Timestamp getTimestamp(int i, java.util.Calendar cal) throws SQLException
{
// If I read the specs, this should use cal only if we don't // If I read the specs, this should use cal only if we don't
// store the timezone, and if we do, then act just like getDate()? // store the timezone, and if we do, then act just like getDate()?
// for now... // for now...
...@@ -309,28 +339,33 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -309,28 +339,33 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public java.sql.Date getDate(String c, java.util.Calendar cal) throws SQLException { public java.sql.Date getDate(String c, java.util.Calendar cal) throws SQLException
{
return getDate(findColumn(c), cal); return getDate(findColumn(c), cal);
} }
public Time getTime(String c, java.util.Calendar cal) throws SQLException { public Time getTime(String c, java.util.Calendar cal) throws SQLException
{
return getTime(findColumn(c), cal); return getTime(findColumn(c), cal);
} }
public Timestamp getTimestamp(String c, java.util.Calendar cal) throws SQLException { public Timestamp getTimestamp(String c, java.util.Calendar cal) throws SQLException
{
return getTimestamp(findColumn(c), cal); return getTimestamp(findColumn(c), cal);
} }
public int getFetchDirection() throws SQLException { public int getFetchDirection() throws SQLException
{
//PostgreSQL normally sends rows first->last //PostgreSQL normally sends rows first->last
return java.sql.ResultSet.FETCH_FORWARD; return java.sql.ResultSet.FETCH_FORWARD;
} }
public int getFetchSize() throws SQLException { public int getFetchSize() throws SQLException
{
// In this implementation we return the entire result set, so // In this implementation we return the entire result set, so
// here return the number of rows we have. Sub-classes can return a proper // here return the number of rows we have. Sub-classes can return a proper
// value // value
...@@ -338,7 +373,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -338,7 +373,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public Object getObject(String columnName, java.util.Map map) throws SQLException { public Object getObject(String columnName, java.util.Map map) throws SQLException
{
return getObject(findColumn(columnName), map); return getObject(findColumn(columnName), map);
} }
...@@ -348,23 +384,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -348,23 +384,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
* an object based on that mapping. The class must implement the SQLData * an object based on that mapping. The class must implement the SQLData
* interface. * interface.
*/ */
public Object getObject(int i, java.util.Map map) throws SQLException { public Object getObject(int i, java.util.Map map) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
public Ref getRef(String columnName) throws SQLException { public Ref getRef(String columnName) throws SQLException
{
return getRef(findColumn(columnName)); return getRef(findColumn(columnName));
} }
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");
} }
public int getRow() throws SQLException { public int getRow() throws SQLException
{
final int rows_size = rows.size(); final int rows_size = rows.size();
if (current_row < 0 || current_row >= rows_size) if (current_row < 0 || current_row >= rows_size)
...@@ -375,12 +415,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -375,12 +415,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
// This one needs some thought, as not all ResultSets come from a statement // This one needs some thought, as not all ResultSets come from a statement
public Statement getStatement() throws SQLException { public Statement getStatement() throws SQLException
{
return statement; return statement;
} }
public int getType() throws SQLException { public int getType() throws SQLException
{
// This implementation allows scrolling but is not able to // This implementation allows scrolling but is not able to
// see any changes. Sub-classes may overide this to return a more // see any changes. Sub-classes may overide this to return a more
// meaningful result. // meaningful result.
...@@ -388,29 +430,34 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -388,29 +430,34 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public boolean isAfterLast() throws SQLException { public boolean isAfterLast() throws SQLException
{
final int rows_size = rows.size(); final int rows_size = rows.size();
return (current_row >= rows_size && rows_size > 0); return (current_row >= rows_size && rows_size > 0);
} }
public boolean isBeforeFirst() throws SQLException { public boolean isBeforeFirst() throws SQLException
{
return (current_row < 0 && rows.size() > 0); return (current_row < 0 && rows.size() > 0);
} }
public boolean isFirst() throws SQLException { public boolean isFirst() throws SQLException
{
return (current_row == 0 && rows.size() >= 0); return (current_row == 0 && rows.size() >= 0);
} }
public boolean isLast() throws SQLException { public boolean isLast() throws SQLException
{
final int rows_size = rows.size(); final int rows_size = rows.size();
return (current_row == rows_size - 1 && rows_size > 0); return (current_row == rows_size - 1 && rows_size > 0);
} }
public boolean last() throws SQLException { public boolean last() throws SQLException
{
final int rows_size = rows.size(); final int rows_size = rows.size();
if (rows_size <= 0) if (rows_size <= 0)
return false; return false;
...@@ -425,7 +472,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -425,7 +472,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public boolean previous() throws SQLException { public boolean previous() throws SQLException
{
if (--current_row < 0) if (--current_row < 0)
return false; return false;
this_row = (byte[][]) rows.elementAt(current_row); this_row = (byte[][]) rows.elementAt(current_row);
...@@ -434,24 +482,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -434,24 +482,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public boolean relative(int rows) throws SQLException { public boolean relative(int rows) throws SQLException
{
//have to add 1 since absolute expects a 1-based index //have to add 1 since absolute expects a 1-based index
return absolute(current_row + 1 + rows); return absolute(current_row + 1 + rows);
} }
public void setFetchDirection(int direction) throws SQLException { public void setFetchDirection(int direction) throws SQLException
{
throw new PSQLException("postgresql.psqlnotimp"); throw new PSQLException("postgresql.psqlnotimp");
} }
public void setFetchSize(int rows) throws SQLException { public void setFetchSize(int rows) throws SQLException
{
// Sub-classes should implement this as part of their cursor support // Sub-classes should implement this as part of their cursor support
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
public synchronized void cancelRowUpdates() throws SQLException public synchronized void cancelRowUpdates()
throws SQLException
{ {
if (doingUpdates) if (doingUpdates)
{ {
...@@ -462,36 +514,45 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -462,36 +514,45 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void deleteRow() throws SQLException public synchronized void deleteRow()
throws SQLException
{
if ( !isUpdateable() )
{ {
if ( !isUpdateable() ) {
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if (onInsertRow) { if (onInsertRow)
{
throw new PSQLException( "postgresql.updateable.oninsertrow" ); throw new PSQLException( "postgresql.updateable.oninsertrow" );
} }
if (rows.size() == 0) { if (rows.size() == 0)
{
throw new PSQLException( "postgresql.updateable.emptydelete" ); throw new PSQLException( "postgresql.updateable.emptydelete" );
} }
if (isBeforeFirst()) { if (isBeforeFirst())
{
throw new PSQLException( "postgresql.updateable.beforestartdelete" ); throw new PSQLException( "postgresql.updateable.beforestartdelete" );
} }
if (isAfterLast()) { if (isAfterLast())
{
throw new PSQLException( "postgresql.updateable.afterlastdelete" ); throw new PSQLException( "postgresql.updateable.afterlastdelete" );
} }
int numKeys = primaryKeys.size(); int numKeys = primaryKeys.size();
if ( deleteStatement == null ) { if ( deleteStatement == null )
{
StringBuffer deleteSQL = new StringBuffer("DELETE FROM " ).append(tableName).append(" where " ); StringBuffer deleteSQL = new StringBuffer("DELETE FROM " ).append(tableName).append(" where " );
for ( int i = 0; i < numKeys; i++ ) { for ( int i = 0; i < numKeys; i++ )
{
deleteSQL.append( ((PrimaryKey) primaryKeys.get(i)).name ).append( " = ? " ); deleteSQL.append( ((PrimaryKey) primaryKeys.get(i)).name ).append( " = ? " );
if ( i < numKeys - 1 ) { if ( i < numKeys - 1 )
{
deleteSQL.append( " and " ); deleteSQL.append( " and " );
} }
} }
...@@ -500,7 +561,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -500,7 +561,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
deleteStatement.clearParameters(); deleteStatement.clearParameters();
for ( int i = 0; i < numKeys; i++ ) { for ( int i = 0; i < numKeys; i++ )
{
deleteStatement.setObject(i + 1, ((PrimaryKey) primaryKeys.get(i)).getValue()); deleteStatement.setObject(i + 1, ((PrimaryKey) primaryKeys.get(i)).getValue());
} }
...@@ -511,15 +573,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -511,15 +573,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void insertRow() throws SQLException { public synchronized void insertRow()
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if (!onInsertRow) { if (!onInsertRow)
{
throw new PSQLException( "postgresql.updateable.notoninsertrow" ); throw new PSQLException( "postgresql.updateable.notoninsertrow" );
} }
else { else
{
// loop through the keys in the insertTable and create the sql statement // loop through the keys in the insertTable and create the sql statement
// we have to create the sql every time since the user could insert different // we have to create the sql every time since the user could insert different
...@@ -531,15 +598,18 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -531,15 +598,18 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
Enumeration columnNames = updateValues.keys(); Enumeration columnNames = updateValues.keys();
int numColumns = updateValues.size(); int numColumns = updateValues.size();
for ( int i = 0; columnNames.hasMoreElements(); i++ ) { for ( int i = 0; columnNames.hasMoreElements(); i++ )
{
String columnName = (String) columnNames.nextElement(); String columnName = (String) columnNames.nextElement();
insertSQL.append( columnName ); insertSQL.append( columnName );
if ( i < numColumns - 1 ) { if ( i < numColumns - 1 )
{
insertSQL.append(", "); insertSQL.append(", ");
paramSQL.append("?,"); paramSQL.append("?,");
} }
else { else
{
paramSQL.append("?)"); paramSQL.append("?)");
} }
...@@ -550,14 +620,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -550,14 +620,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
Enumeration keys = updateValues.keys(); Enumeration keys = updateValues.keys();
for ( int i = 1; keys.hasMoreElements(); i++) { for ( int i = 1; keys.hasMoreElements(); i++)
{
String key = (String) keys.nextElement(); String key = (String) keys.nextElement();
insertStatement.setObject(i, updateValues.get( key ) ); insertStatement.setObject(i, updateValues.get( key ) );
} }
insertStatement.executeUpdate(); insertStatement.executeUpdate();
if ( usingOID ) { if ( usingOID )
{
// we have to get the last inserted OID and put it in the resultset // we have to get the last inserted OID and put it in the resultset
long insertedOID = ((AbstractJdbc2Statement) insertStatement).getLastOID(); long insertedOID = ((AbstractJdbc2Statement) insertStatement).getLastOID();
...@@ -583,8 +655,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -583,8 +655,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void moveToCurrentRow() throws SQLException { public synchronized void moveToCurrentRow()
if (!updateable) { throws SQLException
{
if (!updateable)
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
...@@ -598,7 +673,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -598,7 +673,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void moveToInsertRow() throws SQLException public synchronized void moveToInsertRow()
throws SQLException
{ {
if ( !isUpdateable() ) if ( !isUpdateable() )
{ {
...@@ -620,7 +696,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -620,7 +696,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
private synchronized void clearRowBuffer() throws SQLException private synchronized void clearRowBuffer()
throws SQLException
{ {
// rowBuffer is the temporary storage for the row // rowBuffer is the temporary storage for the row
rowBuffer = new byte[fields.length][]; rowBuffer = new byte[fields.length][];
...@@ -631,19 +708,22 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -631,19 +708,22 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public boolean rowDeleted() throws SQLException { public boolean rowDeleted() throws SQLException
{
// only sub-classes implement CONCURuPDATEABLE // only sub-classes implement CONCURuPDATEABLE
throw Driver.notImplemented(); throw Driver.notImplemented();
} }
public boolean rowInserted() throws SQLException { public boolean rowInserted() throws SQLException
{
// only sub-classes implement CONCURuPDATEABLE // only sub-classes implement CONCURuPDATEABLE
throw Driver.notImplemented(); throw Driver.notImplemented();
} }
public boolean rowUpdated() throws SQLException { public boolean rowUpdated() throws SQLException
{
// only sub-classes implement CONCURuPDATEABLE // only sub-classes implement CONCURuPDATEABLE
throw Driver.notImplemented(); throw Driver.notImplemented();
} }
...@@ -652,21 +732,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -652,21 +732,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public synchronized void updateAsciiStream(int columnIndex, public synchronized void updateAsciiStream(int columnIndex,
java.io.InputStream x, java.io.InputStream x,
int length int length
) throws SQLException { )
throws SQLException
{
if ( !isUpdateable() ) { if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
byte[] theData = null; byte[] theData = null;
try { try
{
x.read(theData, 0, length); x.read(theData, 0, length);
} }
catch (NullPointerException ex ) { catch (NullPointerException ex )
{
throw new PSQLException("postgresql.updateable.inputstream"); throw new PSQLException("postgresql.updateable.inputstream");
} }
catch (IOException ie) { catch (IOException ie)
{
throw new PSQLException("postgresql.updateable.ioerror" + ie); throw new PSQLException("postgresql.updateable.ioerror" + ie);
} }
...@@ -679,9 +765,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -679,9 +765,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public synchronized void updateBigDecimal(int columnIndex, public synchronized void updateBigDecimal(int columnIndex,
java.math.BigDecimal x ) java.math.BigDecimal x )
throws SQLException { throws SQLException
{
if ( !isUpdateable() ) { if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
...@@ -694,22 +782,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -694,22 +782,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public synchronized void updateBinaryStream(int columnIndex, public synchronized void updateBinaryStream(int columnIndex,
java.io.InputStream x, java.io.InputStream x,
int length int length
) throws SQLException { )
throws SQLException
{
if ( !isUpdateable() ) { if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
byte[] theData = null; byte[] theData = null;
try { try
{
x.read(theData, 0, length); x.read(theData, 0, length);
} }
catch ( NullPointerException ex ) { catch ( NullPointerException ex )
{
throw new PSQLException("postgresql.updateable.inputstream"); throw new PSQLException("postgresql.updateable.inputstream");
} }
catch (IOException ie) { catch (IOException ie)
{
throw new PSQLException("postgresql.updateable.ioerror" + ie); throw new PSQLException("postgresql.updateable.ioerror" + ie);
} }
...@@ -720,13 +814,17 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -720,13 +814,17 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateBoolean(int columnIndex, boolean x) throws SQLException { public synchronized void updateBoolean(int columnIndex, boolean x)
throws SQLException
{
if ( !isUpdateable() ) { if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if ( Driver.logDebug ) Driver.debug("updating boolean " + fields[columnIndex - 1].getName() + "=" + x); if ( Driver.logDebug )
Driver.debug("updating boolean " + fields[columnIndex - 1].getName() + "=" + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
updateValues.put( fields[columnIndex - 1].getName(), new Boolean(x) ); updateValues.put( fields[columnIndex - 1].getName(), new Boolean(x) );
...@@ -734,8 +832,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -734,8 +832,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateByte(int columnIndex, byte x) throws SQLException { public synchronized void updateByte(int columnIndex, byte x)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
...@@ -744,9 +845,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -744,9 +845,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateBytes(int columnIndex, byte[] x) throws SQLException { public synchronized void updateBytes(int columnIndex, byte[] x)
throws SQLException
{
if ( !isUpdateable() ) { if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
...@@ -759,22 +863,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -759,22 +863,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public synchronized void updateCharacterStream(int columnIndex, public synchronized void updateCharacterStream(int columnIndex,
java.io.Reader x, java.io.Reader x,
int length int length
) throws SQLException { )
throws SQLException
{
if ( !isUpdateable() ) { if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
char[] theData = null; char[] theData = null;
try { try
{
x.read(theData, 0, length); x.read(theData, 0, length);
} }
catch (NullPointerException ex) { catch (NullPointerException ex)
{
throw new PSQLException("postgresql.updateable.inputstream"); throw new PSQLException("postgresql.updateable.inputstream");
} }
catch (IOException ie) { catch (IOException ie)
{
throw new PSQLException("postgresql.updateable.ioerror" + ie); throw new PSQLException("postgresql.updateable.ioerror" + ie);
} }
...@@ -784,9 +894,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -784,9 +894,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateDate(int columnIndex, java.sql.Date x) throws SQLException { public synchronized void updateDate(int columnIndex, java.sql.Date x)
throws SQLException
{
if ( !isUpdateable() ) { if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
...@@ -795,12 +908,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -795,12 +908,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateDouble(int columnIndex, double x) throws SQLException { public synchronized void updateDouble(int columnIndex, double x)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if ( Driver.logDebug ) Driver.debug("updating double " + fields[columnIndex - 1].getName() + "=" + x); if ( Driver.logDebug )
Driver.debug("updating double " + fields[columnIndex - 1].getName() + "=" + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
updateValues.put( fields[columnIndex - 1].getName(), new Double(x) ); updateValues.put( fields[columnIndex - 1].getName(), new Double(x) );
...@@ -808,12 +925,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -808,12 +925,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateFloat(int columnIndex, float x) throws SQLException { public synchronized void updateFloat(int columnIndex, float x)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if ( Driver.logDebug ) Driver.debug("updating float " + fields[columnIndex - 1].getName() + "=" + x); if ( Driver.logDebug )
Driver.debug("updating float " + fields[columnIndex - 1].getName() + "=" + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
...@@ -822,12 +943,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -822,12 +943,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateInt(int columnIndex, int x) throws SQLException { public synchronized void updateInt(int columnIndex, int x)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if ( Driver.logDebug ) Driver.debug("updating int " + fields[columnIndex - 1].getName() + "=" + x); if ( Driver.logDebug )
Driver.debug("updating int " + fields[columnIndex - 1].getName() + "=" + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
updateValues.put( fields[columnIndex - 1].getName(), new Integer(x) ); updateValues.put( fields[columnIndex - 1].getName(), new Integer(x) );
...@@ -835,12 +960,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -835,12 +960,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateLong(int columnIndex, long x) throws SQLException { public synchronized void updateLong(int columnIndex, long x)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if ( Driver.logDebug ) Driver.debug("updating long " + fields[columnIndex - 1].getName() + "=" + x); if ( Driver.logDebug )
Driver.debug("updating long " + fields[columnIndex - 1].getName() + "=" + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
updateValues.put( fields[columnIndex - 1].getName(), new Long(x) ); updateValues.put( fields[columnIndex - 1].getName(), new Long(x) );
...@@ -848,8 +977,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -848,8 +977,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateNull(int columnIndex) throws SQLException { public synchronized void updateNull(int columnIndex)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
...@@ -860,20 +992,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -860,20 +992,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateObject(int columnIndex, Object x) throws SQLException { public synchronized void updateObject(int columnIndex, Object x)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if ( Driver.logDebug ) Driver.debug("updating object " + fields[columnIndex - 1].getName() + " = " + x); if ( Driver.logDebug )
Driver.debug("updating object " + fields[columnIndex - 1].getName() + " = " + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
updateValues.put( fields[columnIndex - 1].getName(), x ); updateValues.put( fields[columnIndex - 1].getName(), x );
} }
public synchronized void updateObject(int columnIndex, Object x, int scale) throws SQLException { public synchronized void updateObject(int columnIndex, Object x, int scale)
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
...@@ -882,21 +1021,26 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -882,21 +1021,26 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public void refreshRow() throws SQLException { public void refreshRow() throws SQLException
if ( !isUpdateable() ) { {
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
try { try
{
StringBuffer selectSQL = new StringBuffer( "select "); StringBuffer selectSQL = new StringBuffer( "select ");
final int numColumns = java.lang.reflect.Array.getLength(fields); final int numColumns = java.lang.reflect.Array.getLength(fields);
for (int i = 0; i < numColumns; i++ ) { for (int i = 0; i < numColumns; i++ )
{
selectSQL.append( fields[i].getName() ); selectSQL.append( fields[i].getName() );
if ( i < numColumns - 1 ) { if ( i < numColumns - 1 )
{
selectSQL.append(", "); selectSQL.append(", ");
} }
...@@ -906,65 +1050,80 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -906,65 +1050,80 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
int numKeys = primaryKeys.size(); int numKeys = primaryKeys.size();
for ( int i = 0; i < numKeys; i++ ) { for ( int i = 0; i < numKeys; i++ )
{
PrimaryKey primaryKey = ((PrimaryKey) primaryKeys.get(i)); PrimaryKey primaryKey = ((PrimaryKey) primaryKeys.get(i));
selectSQL.append(primaryKey.name).append("= ?"); selectSQL.append(primaryKey.name).append("= ?");
if ( i < numKeys - 1 ) { if ( i < numKeys - 1 )
{
selectSQL.append(" and "); selectSQL.append(" and ");
} }
} }
if ( Driver.logDebug ) Driver.debug("selecting " + selectSQL.toString()); if ( Driver.logDebug )
Driver.debug("selecting " + selectSQL.toString());
selectStatement = ((java.sql.Connection) connection).prepareStatement(selectSQL.toString()); selectStatement = ((java.sql.Connection) connection).prepareStatement(selectSQL.toString());
for ( int j = 0, i = 1; j < numKeys; j++, i++) { for ( int j = 0, i = 1; j < numKeys; j++, i++)
{
selectStatement.setObject( i, ((PrimaryKey) primaryKeys.get(j)).getValue() ); selectStatement.setObject( i, ((PrimaryKey) primaryKeys.get(j)).getValue() );
} }
AbstractJdbc2ResultSet rs = (AbstractJdbc2ResultSet) selectStatement.executeQuery(); AbstractJdbc2ResultSet rs = (AbstractJdbc2ResultSet) selectStatement.executeQuery();
if ( rs.first() ) { if ( rs.first() )
{
rowBuffer = rs.rowBuffer; rowBuffer = rs.rowBuffer;
} }
rows.setElementAt( rowBuffer, current_row ); rows.setElementAt( rowBuffer, current_row );
if ( Driver.logDebug ) Driver.debug("done updates"); if ( Driver.logDebug )
Driver.debug("done updates");
rs.close(); rs.close();
selectStatement.close(); selectStatement.close();
selectStatement = null; selectStatement = null;
} }
catch (Exception e) { catch (Exception e)
if ( Driver.logDebug ) Driver.debug(e.getClass().getName() + e); {
if ( Driver.logDebug )
Driver.debug(e.getClass().getName() + e);
throw new SQLException( e.getMessage() ); throw new SQLException( e.getMessage() );
} }
} }
public synchronized void updateRow() throws SQLException { public synchronized void updateRow()
if ( !isUpdateable() ) { throws SQLException
{
if ( !isUpdateable() )
{
throw new PSQLException( "postgresql.updateable.notupdateable" ); throw new PSQLException( "postgresql.updateable.notupdateable" );
} }
if (doingUpdates) { if (doingUpdates)
{
try { try
{
StringBuffer updateSQL = new StringBuffer("UPDATE " + tableName + " SET "); StringBuffer updateSQL = new StringBuffer("UPDATE " + tableName + " SET ");
int numColumns = updateValues.size(); int numColumns = updateValues.size();
Enumeration columns = updateValues.keys(); Enumeration columns = updateValues.keys();
for (int i = 0; columns.hasMoreElements(); i++ ) { for (int i = 0; columns.hasMoreElements(); i++ )
{
String column = (String) columns.nextElement(); String column = (String) columns.nextElement();
updateSQL.append( column + "= ?"); updateSQL.append( column + "= ?");
if ( i < numColumns - 1 ) { if ( i < numColumns - 1 )
{
updateSQL.append(", "); updateSQL.append(", ");
} }
...@@ -974,25 +1133,30 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -974,25 +1133,30 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
int numKeys = primaryKeys.size(); int numKeys = primaryKeys.size();
for ( int i = 0; i < numKeys; i++ ) { for ( int i = 0; i < numKeys; i++ )
{
PrimaryKey primaryKey = ((PrimaryKey) primaryKeys.get(i)); PrimaryKey primaryKey = ((PrimaryKey) primaryKeys.get(i));
updateSQL.append(primaryKey.name).append("= ?"); updateSQL.append(primaryKey.name).append("= ?");
if ( i < numKeys - 1 ) { if ( i < numKeys - 1 )
{
updateSQL.append(" and "); updateSQL.append(" and ");
} }
} }
if ( Driver.logDebug ) Driver.debug("updating " + updateSQL.toString()); if ( Driver.logDebug )
Driver.debug("updating " + updateSQL.toString());
updateStatement = ((java.sql.Connection) connection).prepareStatement(updateSQL.toString()); updateStatement = ((java.sql.Connection) connection).prepareStatement(updateSQL.toString());
int i = 0; int i = 0;
Iterator iterator = updateValues.values().iterator(); Iterator iterator = updateValues.values().iterator();
for (; iterator.hasNext(); i++) { for (; iterator.hasNext(); i++)
{
updateStatement.setObject( i + 1, iterator.next() ); updateStatement.setObject( i + 1, iterator.next() );
} }
for ( int j = 0; j < numKeys; j++, i++) { for ( int j = 0; j < numKeys; j++, i++)
{
updateStatement.setObject( i + 1, ((PrimaryKey) primaryKeys.get(j)).getValue() ); updateStatement.setObject( i + 1, ((PrimaryKey) primaryKeys.get(j)).getValue() );
} }
...@@ -1003,16 +1167,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1003,16 +1167,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
updateRowBuffer(); updateRowBuffer();
if ( Driver.logDebug ) Driver.debug("copying data"); if ( Driver.logDebug )
Driver.debug("copying data");
System.arraycopy(rowBuffer, 0, this_row, 0, rowBuffer.length); System.arraycopy(rowBuffer, 0, this_row, 0, rowBuffer.length);
rows.setElementAt( rowBuffer, current_row ); rows.setElementAt( rowBuffer, current_row );
if ( Driver.logDebug ) Driver.debug("done updates"); if ( Driver.logDebug )
Driver.debug("done updates");
doingUpdates = false; doingUpdates = false;
} }
catch (Exception e) { catch (Exception e)
if ( Driver.logDebug ) Driver.debug(e.getClass().getName() + e); {
if ( Driver.logDebug )
Driver.debug(e.getClass().getName() + e);
throw new SQLException( e.getMessage() ); throw new SQLException( e.getMessage() );
} }
...@@ -1021,8 +1189,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1021,8 +1189,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateShort(int columnIndex, short x) throws SQLException { public synchronized void updateShort(int columnIndex, short x)
if ( Driver.logDebug ) Driver.debug("in update Short " + fields[columnIndex - 1].getName() + " = " + x); throws SQLException
{
if ( Driver.logDebug )
Driver.debug("in update Short " + fields[columnIndex - 1].getName() + " = " + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
...@@ -1031,8 +1202,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1031,8 +1202,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateString(int columnIndex, String x) throws SQLException { public synchronized void updateString(int columnIndex, String x)
if ( Driver.logDebug ) Driver.debug("in update String " + fields[columnIndex - 1].getName() + " = " + x); throws SQLException
{
if ( Driver.logDebug )
Driver.debug("in update String " + fields[columnIndex - 1].getName() + " = " + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
updateValues.put( fields[columnIndex - 1].getName(), x ); updateValues.put( fields[columnIndex - 1].getName(), x );
...@@ -1040,8 +1214,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1040,8 +1214,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateTime(int columnIndex, Time x) throws SQLException { public synchronized void updateTime(int columnIndex, Time x)
if ( Driver.logDebug ) Driver.debug("in update Time " + fields[columnIndex - 1].getName() + " = " + x); throws SQLException
{
if ( Driver.logDebug )
Driver.debug("in update Time " + fields[columnIndex - 1].getName() + " = " + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
...@@ -1050,8 +1227,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1050,8 +1227,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { public synchronized void updateTimestamp(int columnIndex, Timestamp x)
if ( Driver.logDebug ) Driver.debug("updating Timestamp " + fields[columnIndex - 1].getName() + " = " + x); throws SQLException
{
if ( Driver.logDebug )
Driver.debug("updating Timestamp " + fields[columnIndex - 1].getName() + " = " + x);
doingUpdates = !onInsertRow; doingUpdates = !onInsertRow;
updateValues.put( fields[columnIndex - 1].getName(), x ); updateValues.put( fields[columnIndex - 1].getName(), x );
...@@ -1060,76 +1240,100 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1060,76 +1240,100 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public synchronized void updateNull(String columnName) throws SQLException { public synchronized void updateNull(String columnName)
throws SQLException
{
updateNull(findColumn(columnName)); updateNull(findColumn(columnName));
} }
public synchronized void updateBoolean(String columnName, boolean x) throws SQLException { public synchronized void updateBoolean(String columnName, boolean x)
throws SQLException
{
updateBoolean(findColumn(columnName), x); updateBoolean(findColumn(columnName), x);
} }
public synchronized void updateByte(String columnName, byte x) throws SQLException { public synchronized void updateByte(String columnName, byte x)
throws SQLException
{
updateByte(findColumn(columnName), x); updateByte(findColumn(columnName), x);
} }
public synchronized void updateShort(String columnName, short x) throws SQLException { public synchronized void updateShort(String columnName, short x)
throws SQLException
{
updateShort(findColumn(columnName), x); updateShort(findColumn(columnName), x);
} }
public synchronized void updateInt(String columnName, int x) throws SQLException { public synchronized void updateInt(String columnName, int x)
throws SQLException
{
updateInt(findColumn(columnName), x); updateInt(findColumn(columnName), x);
} }
public synchronized void updateLong(String columnName, long x) throws SQLException { public synchronized void updateLong(String columnName, long x)
throws SQLException
{
updateLong(findColumn(columnName), x); updateLong(findColumn(columnName), x);
} }
public synchronized void updateFloat(String columnName, float x) throws SQLException { public synchronized void updateFloat(String columnName, float x)
throws SQLException
{
updateFloat(findColumn(columnName), x); updateFloat(findColumn(columnName), x);
} }
public synchronized void updateDouble(String columnName, double x) throws SQLException { public synchronized void updateDouble(String columnName, double x)
throws SQLException
{
updateDouble(findColumn(columnName), x); updateDouble(findColumn(columnName), x);
} }
public synchronized void updateBigDecimal(String columnName, BigDecimal x) public synchronized void updateBigDecimal(String columnName, BigDecimal x)
throws SQLException { throws SQLException
{
updateBigDecimal(findColumn(columnName), x); updateBigDecimal(findColumn(columnName), x);
} }
public synchronized void updateString(String columnName, String x) throws SQLException { public synchronized void updateString(String columnName, String x)
throws SQLException
{
updateString(findColumn(columnName), x); updateString(findColumn(columnName), x);
} }
public synchronized void updateBytes(String columnName, byte x[]) throws SQLException { public synchronized void updateBytes(String columnName, byte x[])
throws SQLException
{
updateBytes(findColumn(columnName), x); updateBytes(findColumn(columnName), x);
} }
public synchronized void updateDate(String columnName, java.sql.Date x) public synchronized void updateDate(String columnName, java.sql.Date x)
throws SQLException { throws SQLException
{
updateDate(findColumn(columnName), x); updateDate(findColumn(columnName), x);
} }
public synchronized void updateTime(String columnName, java.sql.Time x) public synchronized void updateTime(String columnName, java.sql.Time x)
throws SQLException { throws SQLException
{
updateTime(findColumn(columnName), x); updateTime(findColumn(columnName), x);
} }
public synchronized void updateTimestamp(String columnName, java.sql.Timestamp x) public synchronized void updateTimestamp(String columnName, java.sql.Timestamp x)
throws SQLException { throws SQLException
{
updateTimestamp(findColumn(columnName), x); updateTimestamp(findColumn(columnName), x);
} }
...@@ -1138,7 +1342,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1138,7 +1342,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
String columnName, String columnName,
java.io.InputStream x, java.io.InputStream x,
int length) int length)
throws SQLException { throws SQLException
{
updateAsciiStream(findColumn(columnName), x, length); updateAsciiStream(findColumn(columnName), x, length);
} }
...@@ -1147,7 +1352,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1147,7 +1352,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
String columnName, String columnName,
java.io.InputStream x, java.io.InputStream x,
int length) int length)
throws SQLException { throws SQLException
{
updateBinaryStream(findColumn(columnName), x, length); updateBinaryStream(findColumn(columnName), x, length);
} }
...@@ -1156,28 +1362,35 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1156,28 +1362,35 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
String columnName, String columnName,
java.io.Reader reader, java.io.Reader reader,
int length) int length)
throws SQLException { throws SQLException
{
updateCharacterStream(findColumn(columnName), reader, length); updateCharacterStream(findColumn(columnName), reader, length);
} }
public synchronized void updateObject(String columnName, Object x, int scale) public synchronized void updateObject(String columnName, Object x, int scale)
throws SQLException { throws SQLException
{
updateObject(findColumn(columnName), x); updateObject(findColumn(columnName), x);
} }
public synchronized void updateObject(String columnName, Object x) throws SQLException { public synchronized void updateObject(String columnName, Object x)
throws SQLException
{
updateObject(findColumn(columnName), x); updateObject(findColumn(columnName), x);
} }
private int _findColumn( String columnName ) { private int _findColumn( String columnName )
{
int i; int i;
final int flen = fields.length; final int flen = fields.length;
for (i = 0; i < flen; ++i) { for (i = 0; i < flen; ++i)
if (fields[i].getName().equalsIgnoreCase(columnName)) { {
if (fields[i].getName().equalsIgnoreCase(columnName))
{
return (i + 1); return (i + 1);
} }
} }
...@@ -1192,18 +1405,23 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1192,18 +1405,23 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
boolean isUpdateable() throws SQLException boolean isUpdateable() throws SQLException
{ {
if (updateable) return true; if (updateable)
return true;
if ( Driver.logDebug ) Driver.debug("checking if rs is updateable"); if ( Driver.logDebug )
Driver.debug("checking if rs is updateable");
parseQuery(); parseQuery();
if ( singleTable == false ) { if ( singleTable == false )
if ( Driver.logDebug ) Driver.debug("not a single table"); {
if ( Driver.logDebug )
Driver.debug("not a single table");
return false; return false;
} }
if ( Driver.logDebug ) Driver.debug("getting primary keys"); if ( Driver.logDebug )
Driver.debug("getting primary keys");
// //
// Contains the primary key? // Contains the primary key?
...@@ -1222,22 +1440,26 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1222,22 +1440,26 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
// if we find the oid then just use it // if we find the oid then just use it
if ( oidIndex > 0 ) { if ( oidIndex > 0 )
{
i++; i++;
primaryKeys.add( new PrimaryKey( oidIndex, "oid" ) ); primaryKeys.add( new PrimaryKey( oidIndex, "oid" ) );
usingOID = true; usingOID = true;
} }
else { else
{
// otherwise go and get the primary keys and create a hashtable of keys // otherwise go and get the primary keys and create a hashtable of keys
java.sql.ResultSet rs = ((java.sql.Connection) connection).getMetaData().getPrimaryKeys("", "", tableName); java.sql.ResultSet rs = ((java.sql.Connection) connection).getMetaData().getPrimaryKeys("", "", tableName);
for (; rs.next(); i++ ) { for (; rs.next(); i++ )
{
String columnName = rs.getString(4); // get the columnName String columnName = rs.getString(4); // get the columnName
int index = findColumn( columnName ); int index = findColumn( columnName );
if ( index > 0 ) { if ( index > 0 )
{
primaryKeys.add( new PrimaryKey(index, columnName ) ); // get the primary key information primaryKeys.add( new PrimaryKey(index, columnName ) ); // get the primary key information
} }
} }
...@@ -1247,21 +1469,25 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1247,21 +1469,25 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
numKeys = primaryKeys.size(); numKeys = primaryKeys.size();
if ( Driver.logDebug ) Driver.debug( "no of keys=" + i ); if ( Driver.logDebug )
Driver.debug( "no of keys=" + i );
if ( i < 1 ) { if ( i < 1 )
{
throw new SQLException("No Primary Keys"); throw new SQLException("No Primary Keys");
} }
updateable = primaryKeys.size() > 0; updateable = primaryKeys.size() > 0;
if ( Driver.logDebug ) Driver.debug( "checking primary key " + updateable ); if ( Driver.logDebug )
Driver.debug( "checking primary key " + updateable );
return updateable; return updateable;
} }
public void parseQuery() { public void parseQuery()
{
String[] l_sqlFragments = ((AbstractJdbc2Statement)statement).getSqlFragments(); String[] l_sqlFragments = ((AbstractJdbc2Statement)statement).getSqlFragments();
String l_sql = l_sqlFragments[0]; String l_sql = l_sqlFragments[0];
StringTokenizer st = new StringTokenizer(l_sql, " \r\t"); StringTokenizer st = new StringTokenizer(l_sql, " \r\t");
...@@ -1270,15 +1496,19 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1270,15 +1496,19 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
singleTable = true; singleTable = true;
while ( !tableFound && !tablesChecked && st.hasMoreTokens() ) { while ( !tableFound && !tablesChecked && st.hasMoreTokens() )
{
name = st.nextToken(); name = st.nextToken();
if ( !tableFound ) { if ( !tableFound )
if (name.toLowerCase().equals("from")) { {
if (name.toLowerCase().equals("from"))
{
tableName = st.nextToken(); tableName = st.nextToken();
tableFound = true; tableFound = true;
} }
} }
else { else
{
tablesChecked = true; tablesChecked = true;
// if the very next token is , then there are multiple tables // if the very next token is , then there are multiple tables
singleTable = !name.equalsIgnoreCase(","); singleTable = !name.equalsIgnoreCase(",");
...@@ -1287,15 +1517,18 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1287,15 +1517,18 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
private void updateRowBuffer() throws SQLException { private void updateRowBuffer() throws SQLException
{
Enumeration columns = updateValues.keys(); Enumeration columns = updateValues.keys();
while ( columns.hasMoreElements() ) { while ( columns.hasMoreElements() )
{
String columnName = (String) columns.nextElement(); String columnName = (String) columns.nextElement();
int columnIndex = _findColumn( columnName ) - 1; int columnIndex = _findColumn( columnName ) - 1;
switch ( connection.getSQLType( fields[columnIndex].getPGType() ) ) { switch ( connection.getSQLType( fields[columnIndex].getPGType() ) )
{
case Types.DECIMAL: case Types.DECIMAL:
case Types.BIGINT: case Types.BIGINT:
...@@ -1313,10 +1546,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1313,10 +1546,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
case Types.REAL: case Types.REAL:
case Types.TINYINT: case Types.TINYINT:
try { try
{
rowBuffer[columnIndex] = String.valueOf( updateValues.get( columnName ) ).getBytes(connection.getEncoding().name() ); rowBuffer[columnIndex] = String.valueOf( updateValues.get( columnName ) ).getBytes(connection.getEncoding().name() );
} }
catch ( UnsupportedEncodingException ex) { catch ( UnsupportedEncodingException ex)
{
throw new SQLException("Unsupported Encoding " + connection.getEncoding().name()); throw new SQLException("Unsupported Encoding " + connection.getEncoding().name());
} }
...@@ -1331,20 +1566,24 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra ...@@ -1331,20 +1566,24 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
} }
public void setStatement(Statement statement) { public void setStatement(Statement statement)
{
this.statement = statement; this.statement = statement;
} }
private class PrimaryKey { private class PrimaryKey
{
int index; // where in the result set is this primaryKey int index; // where in the result set is this primaryKey
String name; // what is the columnName of this primary Key String name; // what is the columnName of this primary Key
PrimaryKey( int index, String name) { PrimaryKey( int index, String name)
{
this.index = index; this.index = index;
this.name = name; this.name = name;
} }
Object getValue() throws SQLException { Object getValue() throws SQLException
{
return getObject(index); return getObject(index);
} }
}; };
......
...@@ -513,40 +513,40 @@ public abstract class AbstractJdbc2ResultSetMetaData extends org.postgresql.jdbc ...@@ -513,40 +513,40 @@ public abstract class AbstractJdbc2ResultSetMetaData extends org.postgresql.jdbc
switch (sql_type) switch (sql_type)
{ {
case Types.BIT: case Types.BIT:
return("java.lang.Boolean"); return ("java.lang.Boolean");
case Types.SMALLINT: case Types.SMALLINT:
return("java.lang.Short"); return ("java.lang.Short");
case Types.INTEGER: case Types.INTEGER:
return("java.lang.Integer"); return ("java.lang.Integer");
case Types.BIGINT: case Types.BIGINT:
return("java.lang.Long"); return ("java.lang.Long");
case Types.NUMERIC: case Types.NUMERIC:
return("java.math.BigDecimal"); return ("java.math.BigDecimal");
case Types.REAL: case Types.REAL:
return("java.lang.Float"); return ("java.lang.Float");
case Types.DOUBLE: case Types.DOUBLE:
return("java.lang.Double"); return ("java.lang.Double");
case Types.CHAR: case Types.CHAR:
case Types.VARCHAR: case Types.VARCHAR:
return("java.lang.String"); return ("java.lang.String");
case Types.DATE: case Types.DATE:
return("java.sql.Date"); return ("java.sql.Date");
case Types.TIME: case Types.TIME:
return("java.sql.Time"); return ("java.sql.Time");
case Types.TIMESTAMP: case Types.TIMESTAMP:
return("java.sql.Timestamp"); return ("java.sql.Timestamp");
case Types.BINARY: case Types.BINARY:
case Types.VARBINARY: case Types.VARBINARY:
return("[B"); return ("[B");
case Types.ARRAY: case Types.ARRAY:
return("java.sql.Array"); return ("java.sql.Array");
default: default:
String type = field.getPGType(); String type = field.getPGType();
if ("unknown".equals(type)) if ("unknown".equals(type))
{ {
return("java.lang.String"); return ("java.lang.String");
} }
return("java.lang.Object"); return ("java.lang.Object");
} }
} }
} }
......
...@@ -8,7 +8,7 @@ import java.util.Vector; ...@@ -8,7 +8,7 @@ import java.util.Vector;
import org.postgresql.largeobject.*; import org.postgresql.largeobject.*;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.5 2002/09/02 03:07:36 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.6 2002/09/06 21:23:06 momjian 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
...@@ -183,12 +183,12 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra ...@@ -183,12 +183,12 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra
// is buffered internally anyhow, so there would be no performance // is buffered internally anyhow, so there would be no performance
// boost gained, if anything it would be worse! // boost gained, if anything it would be worse!
int bytesRemaining = (int)x.length(); int bytesRemaining = (int)x.length();
int numRead = l_inStream.read(buf,0,Math.min(buf.length,bytesRemaining)); int numRead = l_inStream.read(buf, 0, Math.min(buf.length, bytesRemaining));
while (numRead != -1 && bytesRemaining > 0) while (numRead != -1 && bytesRemaining > 0)
{ {
bytesRemaining -= numRead; bytesRemaining -= numRead;
los.write(buf,0,numRead); los.write(buf, 0, numRead);
numRead = l_inStream.read(buf,0,Math.min(buf.length,bytesRemaining)); numRead = l_inStream.read(buf, 0, Math.min(buf.length, bytesRemaining));
} }
los.close(); los.close();
} }
...@@ -385,7 +385,8 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra ...@@ -385,7 +385,8 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra
//This is needed by AbstractJdbc2ResultSet to determine if the query is updateable or not //This is needed by AbstractJdbc2ResultSet to determine if the query is updateable or not
protected String[] getSqlFragments() { protected String[] getSqlFragments()
{
return m_sqlFragments; return m_sqlFragments;
} }
......
...@@ -6,7 +6,7 @@ import java.util.Vector; ...@@ -6,7 +6,7 @@ import java.util.Vector;
import java.util.Hashtable; import java.util.Hashtable;
import org.postgresql.Field; import org.postgresql.Field;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Connection.java,v 1.4 2002/07/26 05:29:35 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Connection.java,v 1.5 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.Connection interface for JDBC2. * This class implements the java.sql.Connection interface for JDBC2.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2Connection or one of it's parents * org.postgresql.jdbc2.AbstractJdbc2Connection or one of it's parents
...@@ -33,7 +33,7 @@ public class Jdbc2Connection extends org.postgresql.jdbc2.AbstractJdbc2Connectio ...@@ -33,7 +33,7 @@ public class Jdbc2Connection extends org.postgresql.jdbc2.AbstractJdbc2Connectio
public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{ {
Jdbc2CallableStatement s = new org.postgresql.jdbc2.Jdbc2CallableStatement(this,sql); Jdbc2CallableStatement s = new org.postgresql.jdbc2.Jdbc2CallableStatement(this, sql);
s.setResultSetType(resultSetType); s.setResultSetType(resultSetType);
s.setResultSetConcurrency(resultSetConcurrency); s.setResultSetConcurrency(resultSetConcurrency);
return s; return s;
......
...@@ -5,7 +5,7 @@ import java.sql.*; ...@@ -5,7 +5,7 @@ import java.sql.*;
import java.util.Vector; import java.util.Vector;
import org.postgresql.Field; import org.postgresql.Field;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.4 2002/08/14 20:35:39 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.5 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.ResultSet interface for JDBC2. * This class implements the java.sql.ResultSet interface for JDBC2.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents * org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents
...@@ -23,11 +23,13 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet ...@@ -23,11 +23,13 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
return new Jdbc2ResultSetMetaData(rows, fields); return new Jdbc2ResultSetMetaData(rows, fields);
} }
public java.sql.Clob getClob(int i) throws SQLException { public java.sql.Clob getClob(int i) throws SQLException
{
return new org.postgresql.jdbc2.Jdbc2Clob(connection, getInt(i)); return new org.postgresql.jdbc2.Jdbc2Clob(connection, getInt(i));
} }
public java.sql.Blob getBlob(int i) throws SQLException { public java.sql.Blob getBlob(int i) throws SQLException
{
return new org.postgresql.jdbc2.Jdbc2Blob(connection, getInt(i)); return new org.postgresql.jdbc2.Jdbc2Blob(connection, getInt(i));
} }
......
...@@ -3,7 +3,7 @@ package org.postgresql.jdbc2; ...@@ -3,7 +3,7 @@ package org.postgresql.jdbc2;
import java.sql.*; import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.2 2002/07/24 22:08:43 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.3 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.Statement interface for JDBC2. * This class implements the java.sql.Statement interface for JDBC2.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2Statement or one of it's parents * org.postgresql.jdbc2.AbstractJdbc2Statement or one of it's parents
......
...@@ -8,16 +8,20 @@ import java.sql.*; ...@@ -8,16 +8,20 @@ import java.sql.*;
* Base class for data sources and related classes. * Base class for data sources and related classes.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public abstract class BaseDataSource implements Referenceable { public abstract class BaseDataSource implements Referenceable
{
// Load the normal driver, since we'll use it to actually connect to the // Load the normal driver, since we'll use it to actually connect to the
// database. That way we don't have to maintain the connecting code in // database. That way we don't have to maintain the connecting code in
// multiple places. // multiple places.
static { static {
try { try
{
Class.forName("org.postgresql.Driver"); Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) { }
catch (ClassNotFoundException e)
{
System.err.println("PostgreSQL DataSource unable to load PostgreSQL JDBC Driver"); System.err.println("PostgreSQL DataSource unable to load PostgreSQL JDBC Driver");
} }
} }
...@@ -42,7 +46,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -42,7 +46,8 @@ public abstract class BaseDataSource implements Referenceable {
* @throws SQLException * @throws SQLException
* Occurs when the database connection cannot be established. * Occurs when the database connection cannot be established.
*/ */
public Connection getConnection() throws SQLException { public Connection getConnection() throws SQLException
{
return getConnection(user, password); return getConnection(user, password);
} }
...@@ -56,15 +61,21 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -56,15 +61,21 @@ public abstract class BaseDataSource implements Referenceable {
* @throws SQLException * @throws SQLException
* Occurs when the database connection cannot be established. * Occurs when the database connection cannot be established.
*/ */
public Connection getConnection(String user, String password) throws SQLException { public Connection getConnection(String user, String password) throws SQLException
try { {
try
{
Connection con = DriverManager.getConnection(getUrl(), user, password); Connection con = DriverManager.getConnection(getUrl(), user, password);
if (logger != null) { if (logger != null)
{
logger.println("Created a non-pooled connection for " + user + " at " + getUrl()); logger.println("Created a non-pooled connection for " + user + " at " + getUrl());
} }
return con; return con;
} catch (SQLException e) { }
if (logger != null) { catch (SQLException e)
{
if (logger != null)
{
logger.println("Failed to create a non-pooled connection for " + user + " at " + getUrl() + ": " + e); logger.println("Failed to create a non-pooled connection for " + user + " at " + getUrl() + ": " + e);
} }
throw e; throw e;
...@@ -75,7 +86,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -75,7 +86,8 @@ public abstract class BaseDataSource implements Referenceable {
* This DataSource does not support a configurable login timeout. * This DataSource does not support a configurable login timeout.
* @return 0 * @return 0
*/ */
public int getLoginTimeout() throws SQLException { public int getLoginTimeout() throws SQLException
{
return 0; return 0;
} }
...@@ -83,27 +95,30 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -83,27 +95,30 @@ public abstract class BaseDataSource implements Referenceable {
* This DataSource does not support a configurable login timeout. Any value * This DataSource does not support a configurable login timeout. Any value
* provided here will be ignored. * provided here will be ignored.
*/ */
public void setLoginTimeout(int i) throws SQLException { public void setLoginTimeout(int i) throws SQLException
} {}
/** /**
* Gets the log writer used to log connections opened. * Gets the log writer used to log connections opened.
*/ */
public PrintWriter getLogWriter() throws SQLException { public PrintWriter getLogWriter() throws SQLException
{
return logger; return logger;
} }
/** /**
* The DataSource will note every connection opened to the provided log writer. * The DataSource will note every connection opened to the provided log writer.
*/ */
public void setLogWriter(PrintWriter printWriter) throws SQLException { public void setLogWriter(PrintWriter printWriter) throws SQLException
{
logger = printWriter; logger = printWriter;
} }
/** /**
* Gets the name of the host the PostgreSQL database is running on. * Gets the name of the host the PostgreSQL database is running on.
*/ */
public String getServerName() { public String getServerName()
{
return serverName; return serverName;
} }
...@@ -112,10 +127,14 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -112,10 +127,14 @@ public abstract class BaseDataSource implements Referenceable {
* is changed, it will only affect future calls to getConnection. The default * is changed, it will only affect future calls to getConnection. The default
* value is <tt>localhost</tt>. * value is <tt>localhost</tt>.
*/ */
public void setServerName(String serverName) { public void setServerName(String serverName)
if(serverName == null || serverName.equals("")) { {
if (serverName == null || serverName.equals(""))
{
this.serverName = "localhost"; this.serverName = "localhost";
} else { }
else
{
this.serverName = serverName; this.serverName = serverName;
} }
} }
...@@ -124,7 +143,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -124,7 +143,8 @@ public abstract class BaseDataSource implements Referenceable {
* Gets the name of the PostgreSQL database, running on the server identified * Gets the name of the PostgreSQL database, running on the server identified
* by the serverName property. * by the serverName property.
*/ */
public String getDatabaseName() { public String getDatabaseName()
{
return databaseName; return databaseName;
} }
...@@ -133,7 +153,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -133,7 +153,8 @@ public abstract class BaseDataSource implements Referenceable {
* by the serverName property. If this is changed, it will only affect * by the serverName property. If this is changed, it will only affect
* future calls to getConnection. * future calls to getConnection.
*/ */
public void setDatabaseName(String databaseName) { public void setDatabaseName(String databaseName)
{
this.databaseName = databaseName; this.databaseName = databaseName;
} }
...@@ -147,7 +168,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -147,7 +168,8 @@ public abstract class BaseDataSource implements Referenceable {
* Gets the user to connect as by default. If this is not specified, you must * Gets the user to connect as by default. If this is not specified, you must
* use the getConnection method which takes a user and password as parameters. * use the getConnection method which takes a user and password as parameters.
*/ */
public String getUser() { public String getUser()
{
return user; return user;
} }
...@@ -156,7 +178,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -156,7 +178,8 @@ public abstract class BaseDataSource implements Referenceable {
* use the getConnection method which takes a user and password as parameters. * use the getConnection method which takes a user and password as parameters.
* If this is changed, it will only affect future calls to getConnection. * If this is changed, it will only affect future calls to getConnection.
*/ */
public void setUser(String user) { public void setUser(String user)
{
this.user = user; this.user = user;
} }
...@@ -165,7 +188,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -165,7 +188,8 @@ public abstract class BaseDataSource implements Referenceable {
* password is needed to log in, you must use the getConnection method which takes * password is needed to log in, you must use the getConnection method which takes
* a user and password as parameters. * a user and password as parameters.
*/ */
public String getPassword() { public String getPassword()
{
return password; return password;
} }
...@@ -175,7 +199,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -175,7 +199,8 @@ public abstract class BaseDataSource implements Referenceable {
* a user and password as parameters. If this is changed, it will only affect * a user and password as parameters. If this is changed, it will only affect
* future calls to getConnection. * future calls to getConnection.
*/ */
public void setPassword(String password) { public void setPassword(String password)
{
this.password = password; this.password = password;
} }
...@@ -185,7 +210,8 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -185,7 +210,8 @@ public abstract class BaseDataSource implements Referenceable {
* *
* @return The port, or 0 if the default port will be used. * @return The port, or 0 if the default port will be used.
*/ */
public int getPortNumber() { public int getPortNumber()
{
return portNumber; return portNumber;
} }
...@@ -194,28 +220,34 @@ public abstract class BaseDataSource implements Referenceable { ...@@ -194,28 +220,34 @@ public abstract class BaseDataSource implements Referenceable {
* connections. Be sure the -i flag is passed to postmaster when PostgreSQL * connections. Be sure the -i flag is passed to postmaster when PostgreSQL
* is started. If this is not set, or set to 0, the default port will be used. * is started. If this is not set, or set to 0, the default port will be used.
*/ */
public void setPortNumber(int portNumber) { public void setPortNumber(int portNumber)
{
this.portNumber = portNumber; this.portNumber = portNumber;
} }
/** /**
* Generates a DriverManager URL from the other properties supplied. * Generates a DriverManager URL from the other properties supplied.
*/ */
private String getUrl() { private String getUrl()
return "jdbc:postgresql://"+serverName+(portNumber == 0 ? "" : ":"+portNumber)+"/"+databaseName; {
return "jdbc:postgresql://" + serverName + (portNumber == 0 ? "" : ":" + portNumber) + "/" + databaseName;
} }
public Reference getReference() throws NamingException { public Reference getReference() throws NamingException
{
Reference ref = new Reference(getClass().getName(), PGObjectFactory.class.getName(), null); Reference ref = new Reference(getClass().getName(), PGObjectFactory.class.getName(), null);
ref.add(new StringRefAddr("serverName", serverName)); ref.add(new StringRefAddr("serverName", serverName));
if (portNumber != 0) { if (portNumber != 0)
{
ref.add(new StringRefAddr("portNumber", Integer.toString(portNumber))); ref.add(new StringRefAddr("portNumber", Integer.toString(portNumber)));
} }
ref.add(new StringRefAddr("databaseName", databaseName)); ref.add(new StringRefAddr("databaseName", databaseName));
if (user != null) { if (user != null)
{
ref.add(new StringRefAddr("user", user)); ref.add(new StringRefAddr("user", user));
} }
if (password != null) { if (password != null)
{
ref.add(new StringRefAddr("password", password)); ref.add(new StringRefAddr("password", password));
} }
return ref; return ref;
......
...@@ -21,16 +21,18 @@ import java.io.Serializable; ...@@ -21,16 +21,18 @@ import java.io.Serializable;
* <p>This implementation supports JDK 1.3 and higher.</p> * <p>This implementation supports JDK 1.3 and higher.</p>
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class ConnectionPool extends BaseDataSource implements Serializable, ConnectionPoolDataSource { public class ConnectionPool extends BaseDataSource implements Serializable, ConnectionPoolDataSource
{
private boolean defaultAutoCommit = false; private boolean defaultAutoCommit = false;
/** /**
* Gets a description of this DataSource. * Gets a description of this DataSource.
*/ */
public String getDescription() { public String getDescription()
return "ConnectionPoolDataSource from "+org.postgresql.Driver.getVersion(); {
return "ConnectionPoolDataSource from " + org.postgresql.Driver.getVersion();
} }
/** /**
...@@ -40,7 +42,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn ...@@ -40,7 +42,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* @throws java.sql.SQLException * @throws java.sql.SQLException
* Occurs when the physical database connection cannot be established. * Occurs when the physical database connection cannot be established.
*/ */
public PooledConnection getPooledConnection() throws SQLException { public PooledConnection getPooledConnection() throws SQLException
{
return new PooledConnectionImpl(getConnection(), defaultAutoCommit); return new PooledConnectionImpl(getConnection(), defaultAutoCommit);
} }
...@@ -51,7 +54,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn ...@@ -51,7 +54,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* @throws java.sql.SQLException * @throws java.sql.SQLException
* Occurs when the physical database connection cannot be established. * Occurs when the physical database connection cannot be established.
*/ */
public PooledConnection getPooledConnection(String user, String password) throws SQLException { public PooledConnection getPooledConnection(String user, String password) throws SQLException
{
return new PooledConnectionImpl(getConnection(user, password), defaultAutoCommit); return new PooledConnectionImpl(getConnection(user, password), defaultAutoCommit);
} }
...@@ -60,7 +64,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn ...@@ -60,7 +64,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* turned on by default. The default value is <tt>false</tt>, so that * turned on by default. The default value is <tt>false</tt>, so that
* autoCommit will be turned off by default. * autoCommit will be turned off by default.
*/ */
public boolean isDefaultAutoCommit() { public boolean isDefaultAutoCommit()
{
return defaultAutoCommit; return defaultAutoCommit;
} }
...@@ -69,7 +74,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn ...@@ -69,7 +74,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* turned on by default. The default value is <tt>false</tt>, so that * turned on by default. The default value is <tt>false</tt>, so that
* autoCommit will be turned off by default. * autoCommit will be turned off by default.
*/ */
public void setDefaultAutoCommit(boolean defaultAutoCommit) { public void setDefaultAutoCommit(boolean defaultAutoCommit)
{
this.defaultAutoCommit = defaultAutoCommit; this.defaultAutoCommit = defaultAutoCommit;
} }
......
...@@ -13,32 +13,43 @@ import java.util.Hashtable; ...@@ -13,32 +13,43 @@ import java.util.Hashtable;
* consistent. * consistent.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class PGObjectFactory implements ObjectFactory { public class PGObjectFactory implements ObjectFactory
{
/** /**
* Dereferences a PostgreSQL DataSource. Other types of references are * Dereferences a PostgreSQL DataSource. Other types of references are
* ignored. * ignored.
*/ */
public Object getObjectInstance(Object obj, Name name, Context nameCtx, public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable environment) throws Exception { Hashtable environment) throws Exception
{
Reference ref = (Reference)obj; Reference ref = (Reference)obj;
if(ref.getClassName().equals(SimpleDataSource.class.getName())) { if (ref.getClassName().equals(SimpleDataSource.class.getName()))
{
return loadSimpleDataSource(ref); return loadSimpleDataSource(ref);
} else if (ref.getClassName().equals(ConnectionPool.class.getName())) { }
else if (ref.getClassName().equals(ConnectionPool.class.getName()))
{
return loadConnectionPool(ref); return loadConnectionPool(ref);
} else if (ref.getClassName().equals(PoolingDataSource.class.getName())) { }
else if (ref.getClassName().equals(PoolingDataSource.class.getName()))
{
return loadPoolingDataSource(ref); return loadPoolingDataSource(ref);
} else { }
else
{
return null; return null;
} }
} }
private Object loadPoolingDataSource(Reference ref) { private Object loadPoolingDataSource(Reference ref)
{
// If DataSource exists, return it // If DataSource exists, return it
String name = getProperty(ref, "dataSourceName"); String name = getProperty(ref, "dataSourceName");
PoolingDataSource pds = PoolingDataSource.getDataSource(name); PoolingDataSource pds = PoolingDataSource.getDataSource(name);
if(pds != null) { if (pds != null)
{
return pds; return pds;
} }
// Otherwise, create a new one // Otherwise, create a new one
...@@ -46,31 +57,37 @@ public class PGObjectFactory implements ObjectFactory { ...@@ -46,31 +57,37 @@ public class PGObjectFactory implements ObjectFactory {
pds.setDataSourceName(name); pds.setDataSourceName(name);
loadBaseDataSource(pds, ref); loadBaseDataSource(pds, ref);
String min = getProperty(ref, "initialConnections"); String min = getProperty(ref, "initialConnections");
if (min != null) { if (min != null)
{
pds.setInitialConnections(Integer.parseInt(min)); pds.setInitialConnections(Integer.parseInt(min));
} }
String max = getProperty(ref, "maxConnections"); String max = getProperty(ref, "maxConnections");
if (max != null) { if (max != null)
{
pds.setMaxConnections(Integer.parseInt(max)); pds.setMaxConnections(Integer.parseInt(max));
} }
return pds; return pds;
} }
private Object loadSimpleDataSource(Reference ref) { private Object loadSimpleDataSource(Reference ref)
{
SimpleDataSource ds = new SimpleDataSource(); SimpleDataSource ds = new SimpleDataSource();
return loadBaseDataSource(ds, ref); return loadBaseDataSource(ds, ref);
} }
private Object loadConnectionPool(Reference ref) { private Object loadConnectionPool(Reference ref)
{
ConnectionPool cp = new ConnectionPool(); ConnectionPool cp = new ConnectionPool();
return loadBaseDataSource(cp, ref); return loadBaseDataSource(cp, ref);
} }
private Object loadBaseDataSource(BaseDataSource ds, Reference ref) { private Object loadBaseDataSource(BaseDataSource ds, Reference ref)
{
ds.setDatabaseName(getProperty(ref, "databaseName")); ds.setDatabaseName(getProperty(ref, "databaseName"));
ds.setPassword(getProperty(ref, "password")); ds.setPassword(getProperty(ref, "password"));
String port = getProperty(ref, "portNumber"); String port = getProperty(ref, "portNumber");
if(port != null) { if (port != null)
{
ds.setPortNumber(Integer.parseInt(port)); ds.setPortNumber(Integer.parseInt(port));
} }
ds.setServerName(getProperty(ref, "serverName")); ds.setServerName(getProperty(ref, "serverName"));
...@@ -78,9 +95,11 @@ public class PGObjectFactory implements ObjectFactory { ...@@ -78,9 +95,11 @@ public class PGObjectFactory implements ObjectFactory {
return ds; return ds;
} }
private String getProperty(Reference ref, String s) { private String getProperty(Reference ref, String s)
{
RefAddr addr = ref.get(s); RefAddr addr = ref.get(s);
if(addr == null) { if (addr == null)
{
return null; return null;
} }
return (String)addr.getContent(); return (String)addr.getContent();
......
...@@ -13,9 +13,10 @@ import java.lang.reflect.*; ...@@ -13,9 +13,10 @@ import java.lang.reflect.*;
* @see ConnectionPool * @see ConnectionPool
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class PooledConnectionImpl implements PooledConnection { public class PooledConnectionImpl implements PooledConnection
{
private List listeners = new LinkedList(); private List listeners = new LinkedList();
private Connection con; private Connection con;
private ConnectionHandler last; private ConnectionHandler last;
...@@ -25,7 +26,8 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -25,7 +26,8 @@ public class PooledConnectionImpl implements PooledConnection {
* Creates a new PooledConnection representing the specified physical * Creates a new PooledConnection representing the specified physical
* connection. * connection.
*/ */
PooledConnectionImpl(Connection con, boolean autoCommit) { PooledConnectionImpl(Connection con, boolean autoCommit)
{
this.con = con; this.con = con;
this.autoCommit = autoCommit; this.autoCommit = autoCommit;
} }
...@@ -34,7 +36,8 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -34,7 +36,8 @@ public class PooledConnectionImpl implements PooledConnection {
* Adds a listener for close or fatal error events on the connection * Adds a listener for close or fatal error events on the connection
* handed out to a client. * handed out to a client.
*/ */
public void addConnectionEventListener(ConnectionEventListener connectionEventListener) { public void addConnectionEventListener(ConnectionEventListener connectionEventListener)
{
listeners.add(connectionEventListener); listeners.add(connectionEventListener);
} }
...@@ -42,7 +45,8 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -42,7 +45,8 @@ public class PooledConnectionImpl implements PooledConnection {
* Removes a listener for close or fatal error events on the connection * Removes a listener for close or fatal error events on the connection
* handed out to a client. * handed out to a client.
*/ */
public void removeConnectionEventListener(ConnectionEventListener connectionEventListener) { public void removeConnectionEventListener(ConnectionEventListener connectionEventListener)
{
listeners.remove(connectionEventListener); listeners.remove(connectionEventListener);
} }
...@@ -51,16 +55,27 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -51,16 +55,27 @@ public class PooledConnectionImpl implements PooledConnection {
* PooledConnection. If any client has a connection based on * PooledConnection. If any client has a connection based on
* this PooledConnection, it is forcibly closed as well. * this PooledConnection, it is forcibly closed as well.
*/ */
public void close() throws SQLException { public void close() throws SQLException
if(last != null) { {
if (last != null)
{
last.close(); last.close();
if(!con.getAutoCommit()) { if (!con.getAutoCommit())
try {con.rollback();} catch (SQLException e) {} {
try
{
con.rollback();
} }
catch (SQLException e)
{}
} }
try { }
try
{
con.close(); con.close();
} finally { }
finally
{
con = null; con = null;
} }
} }
...@@ -76,15 +91,24 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -76,15 +91,24 @@ public class PooledConnectionImpl implements PooledConnection {
* there is a previous handle active when this is called, the previous * there is a previous handle active when this is called, the previous
* one is forcibly closed and its work rolled back.</p> * one is forcibly closed and its work rolled back.</p>
*/ */
public Connection getConnection() throws SQLException { public Connection getConnection() throws SQLException
if(con == null) { {
if (con == null)
{
throw new SQLException("This PooledConnection has already been closed!"); throw new SQLException("This PooledConnection has already been closed!");
} }
// Only one connection can be open at a time from this PooledConnection. See JDBC 2.0 Optional Package spec section 6.2.3 // Only one connection can be open at a time from this PooledConnection. See JDBC 2.0 Optional Package spec section 6.2.3
if(last != null) { if (last != null)
{
last.close(); last.close();
if(!con.getAutoCommit()) { if (!con.getAutoCommit())
try {con.rollback();} catch(SQLException e) {} {
try
{
con.rollback();
}
catch (SQLException e)
{}
} }
con.clearWarnings(); con.clearWarnings();
} }
...@@ -97,13 +121,16 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -97,13 +121,16 @@ public class PooledConnectionImpl implements PooledConnection {
/** /**
* Used to fire a connection event to all listeners. * Used to fire a connection event to all listeners.
*/ */
void fireConnectionClosed() { void fireConnectionClosed()
{
ConnectionEvent evt = null; ConnectionEvent evt = null;
// Copy the listener list so the listener can remove itself during this method call // Copy the listener list so the listener can remove itself during this method call
ConnectionEventListener[] local = (ConnectionEventListener[]) listeners.toArray(new ConnectionEventListener[listeners.size()]); ConnectionEventListener[] local = (ConnectionEventListener[]) listeners.toArray(new ConnectionEventListener[listeners.size()]);
for (int i = 0; i < local.length; i++) { for (int i = 0; i < local.length; i++)
{
ConnectionEventListener listener = local[i]; ConnectionEventListener listener = local[i];
if (evt == null) { if (evt == null)
{
evt = new ConnectionEvent(this); evt = new ConnectionEvent(this);
} }
listener.connectionClosed(evt); listener.connectionClosed(evt);
...@@ -113,13 +140,16 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -113,13 +140,16 @@ public class PooledConnectionImpl implements PooledConnection {
/** /**
* Used to fire a connection event to all listeners. * Used to fire a connection event to all listeners.
*/ */
void fireConnectionFatalError(SQLException e) { void fireConnectionFatalError(SQLException e)
{
ConnectionEvent evt = null; ConnectionEvent evt = null;
// Copy the listener list so the listener can remove itself during this method call // Copy the listener list so the listener can remove itself during this method call
ConnectionEventListener[] local = (ConnectionEventListener[])listeners.toArray(new ConnectionEventListener[listeners.size()]); ConnectionEventListener[] local = (ConnectionEventListener[])listeners.toArray(new ConnectionEventListener[listeners.size()]);
for (int i=0; i<local.length; i++) { for (int i = 0; i < local.length; i++)
{
ConnectionEventListener listener = local[i]; ConnectionEventListener listener = local[i];
if (evt == null) { if (evt == null)
{
evt = new ConnectionEvent(this, e); evt = new ConnectionEvent(this, e);
} }
listener.connectionErrorOccurred(evt); listener.connectionErrorOccurred(evt);
...@@ -133,63 +163,90 @@ public class PooledConnectionImpl implements PooledConnection { ...@@ -133,63 +163,90 @@ public class PooledConnectionImpl implements PooledConnection {
* requires JDK 1.3 or higher, though JDK 1.2 could be supported with a * requires JDK 1.3 or higher, though JDK 1.2 could be supported with a
* 3rd-party proxy package. * 3rd-party proxy package.
*/ */
private class ConnectionHandler implements InvocationHandler { private class ConnectionHandler implements InvocationHandler
{
private Connection con; private Connection con;
private boolean automatic = false; private boolean automatic = false;
public ConnectionHandler(Connection con) { public ConnectionHandler(Connection con)
{
this.con = con; this.con = con;
} }
public Object invoke(Object proxy, Method method, Object[] args) public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable { throws Throwable
{
// From Object // From Object
if(method.getDeclaringClass().getName().equals("java.lang.Object")) { if (method.getDeclaringClass().getName().equals("java.lang.Object"))
if(method.getName().equals("toString")) { {
return "Pooled connection wrapping physical connection "+con; if (method.getName().equals("toString"))
} {
if(method.getName().equals("hashCode")) { return "Pooled connection wrapping physical connection " + con;
}
if (method.getName().equals("hashCode"))
{
return new Integer(con.hashCode()); return new Integer(con.hashCode());
} }
if(method.getName().equals("equals")) { if (method.getName().equals("equals"))
if(args[0] == null) { {
if (args[0] == null)
{
return Boolean.FALSE; return Boolean.FALSE;
} }
try { try
{
return Proxy.isProxyClass(args[0].getClass()) && ((ConnectionHandler) Proxy.getInvocationHandler(args[0])).con == con ? Boolean.TRUE : Boolean.FALSE; return Proxy.isProxyClass(args[0].getClass()) && ((ConnectionHandler) Proxy.getInvocationHandler(args[0])).con == con ? Boolean.TRUE : Boolean.FALSE;
} catch(ClassCastException e) { }
catch (ClassCastException e)
{
return Boolean.FALSE; return Boolean.FALSE;
} }
} }
return method.invoke(con, args); return method.invoke(con, args);
} }
// All the rest is from the Connection interface // All the rest is from the Connection interface
if(method.getName().equals("isClosed")) { if (method.getName().equals("isClosed"))
{
return con == null ? Boolean.TRUE : Boolean.FALSE; return con == null ? Boolean.TRUE : Boolean.FALSE;
} }
if(con == null) { if (con == null)
{
throw new SQLException(automatic ? "Connection has been closed automatically because a new connection was opened for the same PooledConnection or the PooledConnection has been closed" : "Connection has been closed"); throw new SQLException(automatic ? "Connection has been closed automatically because a new connection was opened for the same PooledConnection or the PooledConnection has been closed" : "Connection has been closed");
} }
if(method.getName().equals("close")) { if (method.getName().equals("close"))
{
SQLException ex = null; SQLException ex = null;
if(!con.getAutoCommit()) { if (!con.getAutoCommit())
try {con.rollback();} catch(SQLException e) {ex = e;} {
try
{
con.rollback();
}
catch (SQLException e)
{
ex = e;
}
} }
con.clearWarnings(); con.clearWarnings();
con = null; con = null;
last = null; last = null;
fireConnectionClosed(); fireConnectionClosed();
if(ex != null) { if (ex != null)
{
throw ex; throw ex;
} }
return null; return null;
} else { }
else
{
return method.invoke(con, args); return method.invoke(con, args);
} }
} }
public void close() { public void close()
if(con != null) { {
if (con != null)
{
automatic = true; automatic = true;
} }
con = null; con = null;
......
...@@ -33,12 +33,14 @@ import java.sql.SQLException; ...@@ -33,12 +33,14 @@ import java.sql.SQLException;
* <p>This implementation supports JDK 1.3 and higher.</p> * <p>This implementation supports JDK 1.3 and higher.</p>
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class PoolingDataSource extends BaseDataSource implements DataSource { public class PoolingDataSource extends BaseDataSource implements DataSource
{
private static Map dataSources = new HashMap(); private static Map dataSources = new HashMap();
static PoolingDataSource getDataSource(String name) { static PoolingDataSource getDataSource(String name)
{
return (PoolingDataSource)dataSources.get(name); return (PoolingDataSource)dataSources.get(name);
} }
...@@ -56,8 +58,9 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -56,8 +58,9 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
/** /**
* Gets a description of this DataSource. * Gets a description of this DataSource.
*/ */
public String getDescription() { public String getDescription()
return "Pooling DataSource '"+dataSourceName+" from "+org.postgresql.Driver.getVersion(); {
return "Pooling DataSource '" + dataSourceName + " from " + org.postgresql.Driver.getVersion();
} }
/** /**
...@@ -68,8 +71,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -68,8 +71,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Server Name cannot be changed after the DataSource has been * The Server Name cannot be changed after the DataSource has been
* used. * used.
*/ */
public void setServerName(String serverName) { public void setServerName(String serverName)
if (initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
super.setServerName(serverName); super.setServerName(serverName);
...@@ -83,8 +88,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -83,8 +88,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Database Name cannot be changed after the DataSource has been * The Database Name cannot be changed after the DataSource has been
* used. * used.
*/ */
public void setDatabaseName(String databaseName) { public void setDatabaseName(String databaseName)
if (initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
super.setDatabaseName(databaseName); super.setDatabaseName(databaseName);
...@@ -98,8 +105,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -98,8 +105,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The User cannot be changed after the DataSource has been * The User cannot be changed after the DataSource has been
* used. * used.
*/ */
public void setUser(String user) { public void setUser(String user)
if (initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
super.setUser(user); super.setUser(user);
...@@ -113,8 +122,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -113,8 +122,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Password cannot be changed after the DataSource has been * The Password cannot be changed after the DataSource has been
* used. * used.
*/ */
public void setPassword(String password) { public void setPassword(String password)
if (initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
super.setPassword(password); super.setPassword(password);
...@@ -128,8 +139,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -128,8 +139,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Port Number cannot be changed after the DataSource has been * The Port Number cannot be changed after the DataSource has been
* used. * used.
*/ */
public void setPortNumber(int portNumber) { public void setPortNumber(int portNumber)
if (initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
super.setPortNumber(portNumber); super.setPortNumber(portNumber);
...@@ -140,7 +153,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -140,7 +153,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* is initialized. If you do not call initialize explicitly, it will be * is initialized. If you do not call initialize explicitly, it will be
* initialized the first time a connection is drawn from it. * initialized the first time a connection is drawn from it.
*/ */
public int getInitialConnections() { public int getInitialConnections()
{
return initialConnections; return initialConnections;
} }
...@@ -153,8 +167,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -153,8 +167,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Initial Connections cannot be changed after the DataSource has been * The Initial Connections cannot be changed after the DataSource has been
* used. * used.
*/ */
public void setInitialConnections(int initialConnections) { public void setInitialConnections(int initialConnections)
if (initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
this.initialConnections = initialConnections; this.initialConnections = initialConnections;
...@@ -168,7 +184,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -168,7 +184,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* *
* @return The maximum number of pooled connection allowed, or 0 for no maximum. * @return The maximum number of pooled connection allowed, or 0 for no maximum.
*/ */
public int getMaxConnections() { public int getMaxConnections()
{
return maxConnections; return maxConnections;
} }
...@@ -185,8 +202,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -185,8 +202,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Maximum Connections cannot be changed after the DataSource has been * The Maximum Connections cannot be changed after the DataSource has been
* used. * used.
*/ */
public void setMaxConnections(int maxConnections) { public void setMaxConnections(int maxConnections)
if (initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
this.maxConnections = maxConnections; this.maxConnections = maxConnections;
...@@ -196,7 +215,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -196,7 +215,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Gets the name of this DataSource. This uniquely identifies the DataSource. * Gets the name of this DataSource. This uniquely identifies the DataSource.
* You cannot use more than one DataSource in the same VM with the same name. * You cannot use more than one DataSource in the same VM with the same name.
*/ */
public String getDataSourceName() { public String getDataSourceName()
{
return dataSourceName; return dataSourceName;
} }
...@@ -212,18 +232,24 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -212,18 +232,24 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Another PoolingDataSource with the same dataSourceName already * Another PoolingDataSource with the same dataSourceName already
* exists. * exists.
*/ */
public void setDataSourceName(String dataSourceName) { public void setDataSourceName(String dataSourceName)
if(initialized) { {
if (initialized)
{
throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used");
} }
if(this.dataSourceName != null && dataSourceName != null && dataSourceName.equals(this.dataSourceName)) { if (this.dataSourceName != null && dataSourceName != null && dataSourceName.equals(this.dataSourceName))
return; {
return ;
} }
synchronized(dataSources) { synchronized (dataSources)
if(getDataSource(dataSourceName) != null) { {
throw new IllegalArgumentException("DataSource with name '"+dataSourceName+"' already exists!"); if (getDataSource(dataSourceName) != null)
{
throw new IllegalArgumentException("DataSource with name '" + dataSourceName + "' already exists!");
} }
if (this.dataSourceName != null) { if (this.dataSourceName != null)
{
dataSources.remove(this.dataSourceName); dataSources.remove(this.dataSourceName);
} }
this.dataSourceName = dataSourceName; this.dataSourceName = dataSourceName;
...@@ -241,15 +267,18 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -241,15 +267,18 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Occurs when the initialConnections is greater than zero, but the * Occurs when the initialConnections is greater than zero, but the
* DataSource is not able to create enough physical connections. * DataSource is not able to create enough physical connections.
*/ */
public void initialize() throws SQLException { public void initialize() throws SQLException
synchronized (lock) { {
synchronized (lock)
{
source = new ConnectionPool(); source = new ConnectionPool();
source.setDatabaseName(getDatabaseName()); source.setDatabaseName(getDatabaseName());
source.setPassword(getPassword()); source.setPassword(getPassword());
source.setPortNumber(getPortNumber()); source.setPortNumber(getPortNumber());
source.setServerName(getServerName()); source.setServerName(getServerName());
source.setUser(getUser()); source.setUser(getUser());
while (available.size() < initialConnections) { while (available.size() < initialConnections)
{
available.push(source.getPooledConnection()); available.push(source.getPooledConnection());
} }
initialized = true; initialized = true;
...@@ -265,14 +294,17 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -265,14 +294,17 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Occurs when no pooled connection is available, and a new physical * Occurs when no pooled connection is available, and a new physical
* connection cannot be created. * connection cannot be created.
*/ */
public Connection getConnection(String user, String password) throws SQLException { public Connection getConnection(String user, String password) throws SQLException
{
// If this is for the default user/password, use a pooled connection // If this is for the default user/password, use a pooled connection
if(user == null || if (user == null ||
(user.equals(getUser()) && ((password == null && getPassword() == null) || (password != null && password.equals(getPassword()))))) { (user.equals(getUser()) && ((password == null && getPassword() == null) || (password != null && password.equals(getPassword())))))
{
return getConnection(); return getConnection();
} }
// Otherwise, use a non-pooled connection // Otherwise, use a non-pooled connection
if (!initialized) { if (!initialized)
{
initialize(); initialize();
} }
return super.getConnection(user, password); return super.getConnection(user, password);
...@@ -286,8 +318,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -286,8 +318,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Occurs when no pooled connection is available, and a new physical * Occurs when no pooled connection is available, and a new physical
* connection cannot be created. * connection cannot be created.
*/ */
public Connection getConnection() throws SQLException { public Connection getConnection() throws SQLException
if(!initialized) { {
if (!initialized)
{
initialize(); initialize();
} }
return getPooledConnection(); return getPooledConnection();
...@@ -296,27 +330,36 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -296,27 +330,36 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
/** /**
* Closes this DataSource, and all the pooled connections, whether in use or not. * Closes this DataSource, and all the pooled connections, whether in use or not.
*/ */
public void close() { public void close()
synchronized(lock) { {
while(available.size() > 0) { synchronized (lock)
{
while (available.size() > 0)
{
PooledConnectionImpl pci = (PooledConnectionImpl)available.pop(); PooledConnectionImpl pci = (PooledConnectionImpl)available.pop();
try { try
{
pci.close(); pci.close();
} catch (SQLException e) {
} }
catch (SQLException e)
{}
} }
available = null; available = null;
while (used.size() > 0) { while (used.size() > 0)
{
PooledConnectionImpl pci = (PooledConnectionImpl)used.pop(); PooledConnectionImpl pci = (PooledConnectionImpl)used.pop();
pci.removeConnectionEventListener(connectionEventListener); pci.removeConnectionEventListener(connectionEventListener);
try { try
{
pci.close(); pci.close();
} catch (SQLException e) {
} }
catch (SQLException e)
{}
} }
used = null; used = null;
} }
synchronized (dataSources) { synchronized (dataSources)
{
dataSources.remove(dataSourceName); dataSources.remove(dataSourceName);
} }
} }
...@@ -326,28 +369,38 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -326,28 +369,38 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* present, or create a new one if under the max limit. Will * present, or create a new one if under the max limit. Will
* block if all used and a new one would exceed the max. * block if all used and a new one would exceed the max.
*/ */
private Connection getPooledConnection() throws SQLException { private Connection getPooledConnection() throws SQLException
{
PooledConnection pc = null; PooledConnection pc = null;
synchronized(lock) { synchronized (lock)
if (available == null) { {
if (available == null)
{
throw new SQLException("DataSource has been closed."); throw new SQLException("DataSource has been closed.");
} }
while(true) { while (true)
if(available.size() > 0) { {
if (available.size() > 0)
{
pc = (PooledConnection)available.pop(); pc = (PooledConnection)available.pop();
used.push(pc); used.push(pc);
break; break;
} }
if(maxConnections == 0 || used.size() < maxConnections) { if (maxConnections == 0 || used.size() < maxConnections)
{
pc = source.getPooledConnection(); pc = source.getPooledConnection();
used.push(pc); used.push(pc);
break; break;
} else { }
try { else
{
try
{
// Wake up every second at a minimum // Wake up every second at a minimum
lock.wait(1000L); lock.wait(1000L);
} catch(InterruptedException e) {
} }
catch (InterruptedException e)
{}
} }
} }
} }
...@@ -360,19 +413,26 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -360,19 +413,26 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* on a pooled connection. This is the only way connections are marked * on a pooled connection. This is the only way connections are marked
* as unused. * as unused.
*/ */
private ConnectionEventListener connectionEventListener = new ConnectionEventListener() { private ConnectionEventListener connectionEventListener = new ConnectionEventListener()
public void connectionClosed(ConnectionEvent event) { {
public void connectionClosed(ConnectionEvent event)
{
((PooledConnection)event.getSource()).removeConnectionEventListener(this); ((PooledConnection)event.getSource()).removeConnectionEventListener(this);
synchronized(lock) { synchronized (lock)
if(available == null) { {
return; // DataSource has been closed if (available == null)
{
return ; // DataSource has been closed
} }
boolean removed = used.remove(event.getSource()); boolean removed = used.remove(event.getSource());
if(removed) { if (removed)
{
available.push(event.getSource()); available.push(event.getSource());
// There's now a new connection available // There's now a new connection available
lock.notify(); lock.notify();
} else { }
else
{
// a connection error occured // a connection error occured
} }
} }
...@@ -382,11 +442,14 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -382,11 +442,14 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* This is only called for fatal errors, where the physical connection is * This is only called for fatal errors, where the physical connection is
* useless afterward and should be removed from the pool. * useless afterward and should be removed from the pool.
*/ */
public void connectionErrorOccurred(ConnectionEvent event) { public void connectionErrorOccurred(ConnectionEvent event)
{
((PooledConnection) event.getSource()).removeConnectionEventListener(this); ((PooledConnection) event.getSource()).removeConnectionEventListener(this);
synchronized(lock) { synchronized (lock)
if (available == null) { {
return; // DataSource has been closed if (available == null)
{
return ; // DataSource has been closed
} }
used.remove(event.getSource()); used.remove(event.getSource());
// We're now at least 1 connection under the max // We're now at least 1 connection under the max
...@@ -399,13 +462,16 @@ public class PoolingDataSource extends BaseDataSource implements DataSource { ...@@ -399,13 +462,16 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Adds custom properties for this DataSource to the properties defined in * Adds custom properties for this DataSource to the properties defined in
* the superclass. * the superclass.
*/ */
public Reference getReference() throws NamingException { public Reference getReference() throws NamingException
{
Reference ref = super.getReference(); Reference ref = super.getReference();
ref.add(new StringRefAddr("dataSourceName", dataSourceName)); ref.add(new StringRefAddr("dataSourceName", dataSourceName));
if (initialConnections > 0) { if (initialConnections > 0)
{
ref.add(new StringRefAddr("initialConnections", Integer.toString(initialConnections))); ref.add(new StringRefAddr("initialConnections", Integer.toString(initialConnections)));
} }
if (maxConnections > 0) { if (maxConnections > 0)
{
ref.add(new StringRefAddr("maxConnections", Integer.toString(maxConnections))); ref.add(new StringRefAddr("maxConnections", Integer.toString(maxConnections)));
} }
return ref; return ref;
......
...@@ -10,13 +10,15 @@ import java.io.Serializable; ...@@ -10,13 +10,15 @@ import java.io.Serializable;
* are declared in the superclass. * are declared in the superclass.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class SimpleDataSource extends BaseDataSource implements Serializable, DataSource { public class SimpleDataSource extends BaseDataSource implements Serializable, DataSource
{
/** /**
* Gets a description of this DataSource. * Gets a description of this DataSource.
*/ */
public String getDescription() { public String getDescription()
return "Non-Pooling DataSource from "+org.postgresql.Driver.getVersion(); {
return "Non-Pooling DataSource from " + org.postgresql.Driver.getVersion();
} }
} }
...@@ -26,7 +26,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb ...@@ -26,7 +26,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* @see #getBytes * @see #getBytes
* @since 1.4 * @since 1.4
*/ */
public int setBytes(long pos, byte[] bytes) throws SQLException { public int setBytes(long pos, byte[] bytes) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -51,7 +52,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb ...@@ -51,7 +52,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* @see #getBytes * @see #getBytes
* @since 1.4 * @since 1.4
*/ */
public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -69,7 +71,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb ...@@ -69,7 +71,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* @see #getBinaryStream * @see #getBinaryStream
* @since 1.4 * @since 1.4
*/ */
public java.io.OutputStream setBinaryStream(long pos) throws SQLException { public java.io.OutputStream setBinaryStream(long pos) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -83,7 +86,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb ...@@ -83,7 +86,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* <code>BLOB</code> value * <code>BLOB</code> value
* @since 1.4 * @since 1.4
*/ */
public void truncate(long len) throws SQLException { public void truncate(long len) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
......
...@@ -26,7 +26,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb ...@@ -26,7 +26,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
* *
* @since 1.4 * @since 1.4
*/ */
public int setString(long pos, String str) throws SQLException { public int setString(long pos, String str) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -48,7 +49,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb ...@@ -48,7 +49,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
* *
* @since 1.4 * @since 1.4
*/ */
public int setString(long pos, String str, int offset, int len) throws SQLException { public int setString(long pos, String str, int offset, int len) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -66,7 +68,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb ...@@ -66,7 +68,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
* *
* @since 1.4 * @since 1.4
*/ */
public java.io.OutputStream setAsciiStream(long pos) throws SQLException { public java.io.OutputStream setAsciiStream(long pos) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -85,7 +88,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb ...@@ -85,7 +88,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
* *
* @since 1.4 * @since 1.4
*/ */
public java.io.Writer setCharacterStream(long pos) throws SQLException { public java.io.Writer setCharacterStream(long pos) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -100,7 +104,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb ...@@ -100,7 +104,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
* *
* @since 1.4 * @since 1.4
*/ */
public void truncate(long len) throws SQLException { public void truncate(long len) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
......
...@@ -2,7 +2,7 @@ package org.postgresql.jdbc3; ...@@ -2,7 +2,7 @@ package org.postgresql.jdbc3;
import java.sql.*; import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.1 2002/08/14 20:35:39 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
* This class defines methods of the jdbc3 specification. This class extends * This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2Connection which provides the jdbc2 * org.postgresql.jdbc2.AbstractJdbc2Connection which provides the jdbc2
* methods. The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection * methods. The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection
...@@ -25,7 +25,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -25,7 +25,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see ResultSet * @see ResultSet
* @since 1.4 * @since 1.4
*/ */
public void setHoldability(int holdability) throws SQLException { public void setHoldability(int holdability) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -41,7 +42,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -41,7 +42,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see ResultSet * @see ResultSet
* @since 1.4 * @since 1.4
*/ */
public int getHoldability() throws SQLException { public int getHoldability() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -56,7 +58,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -56,7 +58,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see Savepoint * @see Savepoint
* @since 1.4 * @since 1.4
*/ */
public Savepoint setSavepoint() throws SQLException { public Savepoint setSavepoint() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -72,7 +75,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -72,7 +75,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see Savepoint * @see Savepoint
* @since 1.4 * @since 1.4
*/ */
public Savepoint setSavepoint(String name) throws SQLException { public Savepoint setSavepoint(String name) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -91,7 +95,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -91,7 +95,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see #rollback * @see #rollback
* @since 1.4 * @since 1.4
*/ */
public void rollback(Savepoint savepoint) throws SQLException { public void rollback(Savepoint savepoint) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -107,7 +112,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -107,7 +112,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* savepoint in the current transaction * savepoint in the current transaction
* @since 1.4 * @since 1.4
*/ */
public void releaseSavepoint(Savepoint savepoint) throws SQLException { public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -143,7 +149,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -143,7 +149,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4 * @since 1.4
*/ */
public Statement createStatement(int resultSetType, int resultSetConcurrency, public Statement createStatement(int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException { int resultSetHoldability) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -185,7 +192,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -185,7 +192,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
*/ */
public PreparedStatement prepareStatement(String sql, int resultSetType, public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency, int resultSetHoldability) int resultSetConcurrency, int resultSetHoldability)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -224,7 +232,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -224,7 +232,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
*/ */
public CallableStatement prepareCall(String sql, int resultSetType, public CallableStatement prepareCall(String sql, int resultSetType,
int resultSetConcurrency, int resultSetConcurrency,
int resultSetHoldability) throws SQLException { int resultSetHoldability) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -269,7 +278,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -269,7 +278,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4 * @since 1.4
*/ */
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -314,7 +324,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -314,7 +324,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4 * @since 1.4
*/ */
public PreparedStatement prepareStatement(String sql, int columnIndexes[]) public PreparedStatement prepareStatement(String sql, int columnIndexes[])
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -359,7 +370,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -359,7 +370,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4 * @since 1.4
*/ */
public PreparedStatement prepareStatement(String sql, String columnNames[]) public PreparedStatement prepareStatement(String sql, String columnNames[])
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
......
...@@ -20,7 +20,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -20,7 +20,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public boolean supportsSavepoints() throws SQLException { public boolean supportsSavepoints() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -33,7 +34,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -33,7 +34,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public boolean supportsNamedParameters() throws SQLException { public boolean supportsNamedParameters() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -48,7 +50,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -48,7 +50,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a datanase access error occurs * @exception SQLException if a datanase access error occurs
* @since 1.4 * @since 1.4
*/ */
public boolean supportsMultipleOpenResults() throws SQLException { public boolean supportsMultipleOpenResults() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -61,7 +64,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -61,7 +64,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public boolean supportsGetGeneratedKeys() throws SQLException { public boolean supportsGetGeneratedKeys() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -106,7 +110,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -106,7 +110,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @since 1.4 * @since 1.4
*/ */
public ResultSet getSuperTypes(String catalog, String schemaPattern, public ResultSet getSuperTypes(String catalog, String schemaPattern,
String typeNamePattern) throws SQLException { String typeNamePattern) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -144,7 +149,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -144,7 +149,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @since 1.4 * @since 1.4
*/ */
public ResultSet getSuperTables(String catalog, String schemaPattern, public ResultSet getSuperTables(String catalog, String schemaPattern,
String tableNamePattern) throws SQLException { String tableNamePattern) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -220,7 +226,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -220,7 +226,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
*/ */
public ResultSet getAttributes(String catalog, String schemaPattern, public ResultSet getAttributes(String catalog, String schemaPattern,
String typeNamePattern, String attributeNamePattern) String typeNamePattern, String attributeNamePattern)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -235,7 +242,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -235,7 +242,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @see Connection * @see Connection
* @since 1.4 * @since 1.4
*/ */
public boolean supportsResultSetHoldability(int holdability) throws SQLException { public boolean supportsResultSetHoldability(int holdability) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -249,7 +257,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -249,7 +257,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public int getResultSetHoldability() throws SQLException { public int getResultSetHoldability() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -260,7 +269,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -260,7 +269,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public int getDatabaseMajorVersion() throws SQLException { public int getDatabaseMajorVersion() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -271,7 +281,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -271,7 +281,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public int getDatabaseMinorVersion() throws SQLException { public int getDatabaseMinorVersion() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -283,7 +294,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -283,7 +294,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public int getJDBCMajorVersion() throws SQLException { public int getJDBCMajorVersion() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -295,7 +307,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -295,7 +307,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public int getJDBCMinorVersion() throws SQLException { public int getJDBCMinorVersion() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -308,7 +321,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -308,7 +321,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @throws SQLException if a database access error occurs * @throws SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public int getSQLStateType() throws SQLException { public int getSQLStateType() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -320,7 +334,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -320,7 +334,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @throws SQLException if a database access error occurs * @throws SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public boolean locatorsUpdateCopy() throws SQLException { public boolean locatorsUpdateCopy() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -332,7 +347,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -332,7 +347,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @throws SQLExcpetion if a database access error occurs * @throws SQLExcpetion if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public boolean supportsStatementPooling() throws SQLException { public boolean supportsStatementPooling() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
......
...@@ -4,14 +4,16 @@ package org.postgresql.jdbc3; ...@@ -4,14 +4,16 @@ package org.postgresql.jdbc3;
import java.sql.*; import java.sql.*;
import java.util.Vector; import java.util.Vector;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.1 2002/08/14 20:35:39 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
* This class defines methods of the jdbc3 specification. This class extends * This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2ResultSet which provides the jdbc2 * org.postgresql.jdbc2.AbstractJdbc2ResultSet which provides the jdbc2
* methods. The real Statement class (for jdbc3) is org.postgresql.jdbc3.Jdbc3ResultSet * methods. The real Statement class (for jdbc3) is org.postgresql.jdbc3.Jdbc3ResultSet
*/ */
public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet { public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
{
public AbstractJdbc3ResultSet(org.postgresql.PGConnection conn, Statement statement, org.postgresql.Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) { public AbstractJdbc3ResultSet(org.postgresql.PGConnection conn, Statement statement, org.postgresql.Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super (conn, statement, fields, tuples, status, updateCount, insertOID, binaryCursor); super (conn, statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
} }
...@@ -28,7 +30,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -28,7 +30,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* or if a URL is malformed * or if a URL is malformed
* @since 1.4 * @since 1.4
*/ */
public java.net.URL getURL(int columnIndex) throws SQLException { public java.net.URL getURL(int columnIndex) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -45,7 +48,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -45,7 +48,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* or if a URL is malformed * or if a URL is malformed
* @since 1.4 * @since 1.4
*/ */
public java.net.URL getURL(String columnName) throws SQLException { public java.net.URL getURL(String columnName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -61,7 +65,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -61,7 +65,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateRef(int columnIndex, java.sql.Ref x) throws SQLException { public void updateRef(int columnIndex, java.sql.Ref x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -77,7 +82,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -77,7 +82,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateRef(String columnName, java.sql.Ref x) throws SQLException { public void updateRef(String columnName, java.sql.Ref x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -93,7 +99,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -93,7 +99,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateBlob(int columnIndex, java.sql.Blob x) throws SQLException { public void updateBlob(int columnIndex, java.sql.Blob x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -109,7 +116,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -109,7 +116,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateBlob(String columnName, java.sql.Blob x) throws SQLException { public void updateBlob(String columnName, java.sql.Blob x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -125,7 +133,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -125,7 +133,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateClob(int columnIndex, java.sql.Clob x) throws SQLException { public void updateClob(int columnIndex, java.sql.Clob x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -141,7 +150,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -141,7 +150,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateClob(String columnName, java.sql.Clob x) throws SQLException { public void updateClob(String columnName, java.sql.Clob x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -157,7 +167,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -157,7 +167,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateArray(int columnIndex, java.sql.Array x) throws SQLException { public void updateArray(int columnIndex, java.sql.Array x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -173,7 +184,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra ...@@ -173,7 +184,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void updateArray(String columnName, java.sql.Array x) throws SQLException { public void updateArray(String columnName, java.sql.Array x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
......
...@@ -5,7 +5,7 @@ import java.math.BigDecimal; ...@@ -5,7 +5,7 @@ import java.math.BigDecimal;
import java.sql.*; import java.sql.*;
import java.util.Calendar; import java.util.Calendar;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Statement.java,v 1.1 2002/08/14 20:35:39 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Statement.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
* This class defines methods of the jdbc3 specification. This class extends * This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2Statement which provides the jdbc2 * org.postgresql.jdbc2.AbstractJdbc2Statement which provides the jdbc2
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc3.Jdbc3Statement * methods. The real Statement class (for jdbc2) is org.postgresql.jdbc3.Jdbc3Statement
...@@ -48,7 +48,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -48,7 +48,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
* @see #execute * @see #execute
*/ */
public boolean getMoreResults(int current) throws SQLException { public boolean getMoreResults(int current) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -63,7 +64,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -63,7 +64,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public ResultSet getGeneratedKeys() throws SQLException { public ResultSet getGeneratedKeys() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -89,7 +91,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -89,7 +91,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* the given constant is not one of those allowed * the given constant is not one of those allowed
* @since 1.4 * @since 1.4
*/ */
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -111,7 +114,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -111,7 +114,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* statement returns a <code>ResultSet</code> object * statement returns a <code>ResultSet</code> object
* @since 1.4 * @since 1.4
*/ */
public int executeUpdate(String sql, int columnIndexes[]) throws SQLException { public int executeUpdate(String sql, int columnIndexes[]) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -132,7 +136,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -132,7 +136,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* *
* @since 1.4 * @since 1.4
*/ */
public int executeUpdate(String sql, String columnNames[]) throws SQLException { public int executeUpdate(String sql, String columnNames[]) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -172,7 +177,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -172,7 +177,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* *
* @since 1.4 * @since 1.4
*/ */
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -211,7 +217,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -211,7 +217,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* *
* @since 1.4 * @since 1.4
*/ */
public boolean execute(String sql, int columnIndexes[]) throws SQLException { public boolean execute(String sql, int columnIndexes[]) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -251,7 +258,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -251,7 +258,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* *
* @since 1.4 * @since 1.4
*/ */
public boolean execute(String sql, String columnNames[]) throws SQLException { public boolean execute(String sql, String columnNames[]) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -265,7 +273,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -265,7 +273,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* *
* @since 1.4 * @since 1.4
*/ */
public int getResultSetHoldability() throws SQLException { public int getResultSetHoldability() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -279,7 +288,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -279,7 +288,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void setURL(int parameterIndex, java.net.URL x) throws SQLException { public void setURL(int parameterIndex, java.net.URL x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -294,7 +304,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -294,7 +304,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see ParameterMetaData * @see ParameterMetaData
* @since 1.4 * @since 1.4
*/ */
public ParameterMetaData getParameterMetaData() throws SQLException { public ParameterMetaData getParameterMetaData() throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -323,7 +334,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -323,7 +334,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see Types * @see Types
*/ */
public void registerOutParameter(String parameterName, int sqlType) public void registerOutParameter(String parameterName, int sqlType)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -349,7 +361,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -349,7 +361,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see Types * @see Types
*/ */
public void registerOutParameter(String parameterName, int sqlType, int scale) public void registerOutParameter(String parameterName, int sqlType, int scale)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -388,7 +401,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -388,7 +401,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void registerOutParameter (String parameterName, int sqlType, String typeName) public void registerOutParameter (String parameterName, int sqlType, String typeName)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -406,7 +420,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -406,7 +420,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setURL * @see #setURL
* @since 1.4 * @since 1.4
*/ */
public java.net.URL getURL(int parameterIndex) throws SQLException { public java.net.URL getURL(int parameterIndex) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -422,7 +437,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -422,7 +437,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getURL * @see #getURL
* @since 1.4 * @since 1.4
*/ */
public void setURL(String parameterName, java.net.URL val) throws SQLException { public void setURL(String parameterName, java.net.URL val) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -436,7 +452,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -436,7 +452,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public void setNull(String parameterName, int sqlType) throws SQLException { public void setNull(String parameterName, int sqlType) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -451,7 +468,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -451,7 +468,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getBoolean * @see #getBoolean
* @since 1.4 * @since 1.4
*/ */
public void setBoolean(String parameterName, boolean x) throws SQLException { public void setBoolean(String parameterName, boolean x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -466,7 +484,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -466,7 +484,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getByte * @see #getByte
* @since 1.4 * @since 1.4
*/ */
public void setByte(String parameterName, byte x) throws SQLException { public void setByte(String parameterName, byte x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -481,7 +500,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -481,7 +500,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getShort * @see #getShort
* @since 1.4 * @since 1.4
*/ */
public void setShort(String parameterName, short x) throws SQLException { public void setShort(String parameterName, short x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -496,7 +516,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -496,7 +516,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getInt * @see #getInt
* @since 1.4 * @since 1.4
*/ */
public void setInt(String parameterName, int x) throws SQLException { public void setInt(String parameterName, int x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -511,7 +532,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -511,7 +532,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getLong * @see #getLong
* @since 1.4 * @since 1.4
*/ */
public void setLong(String parameterName, long x) throws SQLException { public void setLong(String parameterName, long x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -526,7 +548,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -526,7 +548,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getFloat * @see #getFloat
* @since 1.4 * @since 1.4
*/ */
public void setFloat(String parameterName, float x) throws SQLException { public void setFloat(String parameterName, float x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -541,7 +564,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -541,7 +564,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getDouble * @see #getDouble
* @since 1.4 * @since 1.4
*/ */
public void setDouble(String parameterName, double x) throws SQLException { public void setDouble(String parameterName, double x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -557,7 +581,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -557,7 +581,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getBigDecimal * @see #getBigDecimal
* @since 1.4 * @since 1.4
*/ */
public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -575,7 +600,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -575,7 +600,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getString * @see #getString
* @since 1.4 * @since 1.4
*/ */
public void setString(String parameterName, String x) throws SQLException { public void setString(String parameterName, String x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -592,7 +618,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -592,7 +618,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getBytes * @see #getBytes
* @since 1.4 * @since 1.4
*/ */
public void setBytes(String parameterName, byte x[]) throws SQLException { public void setBytes(String parameterName, byte x[]) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -608,7 +635,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -608,7 +635,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setDate(String parameterName, java.sql.Date x) public void setDate(String parameterName, java.sql.Date x)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -624,7 +652,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -624,7 +652,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setTime(String parameterName, java.sql.Time x) public void setTime(String parameterName, java.sql.Time x)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -641,7 +670,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -641,7 +670,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setTimestamp(String parameterName, java.sql.Timestamp x) public void setTimestamp(String parameterName, java.sql.Timestamp x)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -665,7 +695,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -665,7 +695,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setAsciiStream(String parameterName, java.io.InputStream x, int length) public void setAsciiStream(String parameterName, java.io.InputStream x, int length)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -688,7 +719,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -688,7 +719,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setBinaryStream(String parameterName, java.io.InputStream x, public void setBinaryStream(String parameterName, java.io.InputStream x,
int length) throws SQLException { int length) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -725,7 +757,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -725,7 +757,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setObject(String parameterName, Object x, int targetSqlType, int scale) public void setObject(String parameterName, Object x, int targetSqlType, int scale)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -743,7 +776,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -743,7 +776,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setObject(String parameterName, Object x, int targetSqlType) public void setObject(String parameterName, Object x, int targetSqlType)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -779,7 +813,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -779,7 +813,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getObject * @see #getObject
* @since 1.4 * @since 1.4
*/ */
public void setObject(String parameterName, Object x) throws SQLException { public void setObject(String parameterName, Object x) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -806,7 +841,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -806,7 +841,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
*/ */
public void setCharacterStream(String parameterName, public void setCharacterStream(String parameterName,
java.io.Reader reader, java.io.Reader reader,
int length) throws SQLException { int length) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -829,7 +865,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -829,7 +865,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setDate(String parameterName, java.sql.Date x, Calendar cal) public void setDate(String parameterName, java.sql.Date x, Calendar cal)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -852,7 +889,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -852,7 +889,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setTime(String parameterName, java.sql.Time x, Calendar cal) public void setTime(String parameterName, java.sql.Time x, Calendar cal)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -875,7 +913,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -875,7 +913,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal) public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -909,7 +948,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -909,7 +948,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public void setNull (String parameterName, int sqlType, String typeName) public void setNull (String parameterName, int sqlType, String typeName)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -930,7 +970,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -930,7 +970,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setString * @see #setString
* @since 1.4 * @since 1.4
*/ */
public String getString(String parameterName) throws SQLException { public String getString(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -944,7 +985,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -944,7 +985,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setBoolean * @see #setBoolean
* @since 1.4 * @since 1.4
*/ */
public boolean getBoolean(String parameterName) throws SQLException { public boolean getBoolean(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -958,7 +1000,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -958,7 +1000,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setByte * @see #setByte
* @since 1.4 * @since 1.4
*/ */
public byte getByte(String parameterName) throws SQLException { public byte getByte(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -972,7 +1015,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -972,7 +1015,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setShort * @see #setShort
* @since 1.4 * @since 1.4
*/ */
public short getShort(String parameterName) throws SQLException { public short getShort(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -987,7 +1031,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -987,7 +1031,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setInt * @see #setInt
* @since 1.4 * @since 1.4
*/ */
public int getInt(String parameterName) throws SQLException { public int getInt(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1002,7 +1047,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1002,7 +1047,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setLong * @see #setLong
* @since 1.4 * @since 1.4
*/ */
public long getLong(String parameterName) throws SQLException { public long getLong(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1016,7 +1062,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1016,7 +1062,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setFloat * @see #setFloat
* @since 1.4 * @since 1.4
*/ */
public float getFloat(String parameterName) throws SQLException { public float getFloat(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1030,7 +1077,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1030,7 +1077,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setDouble * @see #setDouble
* @since 1.4 * @since 1.4
*/ */
public double getDouble(String parameterName) throws SQLException { public double getDouble(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1045,7 +1093,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1045,7 +1093,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setBytes * @see #setBytes
* @since 1.4 * @since 1.4
*/ */
public byte[] getBytes(String parameterName) throws SQLException { public byte[] getBytes(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1059,7 +1108,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1059,7 +1108,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setDate * @see #setDate
* @since 1.4 * @since 1.4
*/ */
public java.sql.Date getDate(String parameterName) throws SQLException { public java.sql.Date getDate(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1073,7 +1123,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1073,7 +1123,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setTime * @see #setTime
* @since 1.4 * @since 1.4
*/ */
public java.sql.Time getTime(String parameterName) throws SQLException { public java.sql.Time getTime(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1087,7 +1138,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1087,7 +1138,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setTimestamp * @see #setTimestamp
* @since 1.4 * @since 1.4
*/ */
public java.sql.Timestamp getTimestamp(String parameterName) throws SQLException { public java.sql.Timestamp getTimestamp(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1108,7 +1160,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1108,7 +1160,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setObject * @see #setObject
* @since 1.4 * @since 1.4
*/ */
public Object getObject(String parameterName) throws SQLException { public Object getObject(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1123,7 +1176,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1123,7 +1176,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setBigDecimal * @see #setBigDecimal
* @since 1.4 * @since 1.4
*/ */
public BigDecimal getBigDecimal(String parameterName) throws SQLException { public BigDecimal getBigDecimal(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1144,7 +1198,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1144,7 +1198,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setObject * @see #setObject
* @since 1.4 * @since 1.4
*/ */
public Object getObject (String parameterName, java.util.Map map) throws SQLException { public Object getObject (String parameterName, java.util.Map map) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1159,7 +1214,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1159,7 +1214,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public Ref getRef (String parameterName) throws SQLException { public Ref getRef (String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1174,7 +1230,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1174,7 +1230,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public Blob getBlob (String parameterName) throws SQLException { public Blob getBlob (String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1188,7 +1245,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1188,7 +1245,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public Clob getClob (String parameterName) throws SQLException { public Clob getClob (String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1203,7 +1261,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1203,7 +1261,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @since 1.4 * @since 1.4
*/ */
public Array getArray (String parameterName) throws SQLException { public Array getArray (String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1227,7 +1286,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1227,7 +1286,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public java.sql.Date getDate(String parameterName, Calendar cal) public java.sql.Date getDate(String parameterName, Calendar cal)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1251,7 +1311,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1251,7 +1311,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public java.sql.Time getTime(String parameterName, Calendar cal) public java.sql.Time getTime(String parameterName, Calendar cal)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1276,7 +1337,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1276,7 +1337,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4 * @since 1.4
*/ */
public java.sql.Timestamp getTimestamp(String parameterName, Calendar cal) public java.sql.Timestamp getTimestamp(String parameterName, Calendar cal)
throws SQLException { throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
...@@ -1293,7 +1355,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra ...@@ -1293,7 +1355,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setURL * @see #setURL
* @since 1.4 * @since 1.4
*/ */
public java.net.URL getURL(String parameterName) throws SQLException { public java.net.URL getURL(String parameterName) throws SQLException
{
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
......
...@@ -6,7 +6,7 @@ import java.util.Vector; ...@@ -6,7 +6,7 @@ import java.util.Vector;
import java.util.Hashtable; import java.util.Hashtable;
import org.postgresql.Field; import org.postgresql.Field;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Connection.java,v 1.1 2002/08/14 20:35:40 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Connection.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.Connection interface for JDBC3. * This class implements the java.sql.Connection interface for JDBC3.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Connection or one of it's parents * org.postgresql.jdbc3.AbstractJdbc3Connection or one of it's parents
...@@ -33,7 +33,7 @@ public class Jdbc3Connection extends org.postgresql.jdbc3.AbstractJdbc3Connectio ...@@ -33,7 +33,7 @@ public class Jdbc3Connection extends org.postgresql.jdbc3.AbstractJdbc3Connectio
public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{ {
Jdbc3CallableStatement s = new Jdbc3CallableStatement(this,sql); Jdbc3CallableStatement s = new Jdbc3CallableStatement(this, sql);
s.setResultSetType(resultSetType); s.setResultSetType(resultSetType);
s.setResultSetConcurrency(resultSetConcurrency); s.setResultSetConcurrency(resultSetConcurrency);
return s; return s;
......
...@@ -5,7 +5,7 @@ import java.sql.*; ...@@ -5,7 +5,7 @@ import java.sql.*;
import java.util.Vector; import java.util.Vector;
import org.postgresql.Field; import org.postgresql.Field;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.1 2002/08/14 20:35:40 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.ResultSet interface for JDBC3. * This class implements the java.sql.ResultSet interface for JDBC3.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents * org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents
...@@ -23,11 +23,13 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet ...@@ -23,11 +23,13 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
return new Jdbc3ResultSetMetaData(rows, fields); return new Jdbc3ResultSetMetaData(rows, fields);
} }
public java.sql.Clob getClob(int i) throws SQLException { public java.sql.Clob getClob(int i) throws SQLException
{
return new Jdbc3Clob(connection, getInt(i)); return new Jdbc3Clob(connection, getInt(i));
} }
public java.sql.Blob getBlob(int i) throws SQLException { public java.sql.Blob getBlob(int i) throws SQLException
{
return new Jdbc3Blob(connection, getInt(i)); return new Jdbc3Blob(connection, getInt(i));
} }
......
...@@ -3,7 +3,7 @@ package org.postgresql.jdbc3; ...@@ -3,7 +3,7 @@ package org.postgresql.jdbc3;
import java.sql.*; import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.1 2002/08/14 20:35:40 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
* This class implements the java.sql.Statement interface for JDBC3. * This class implements the java.sql.Statement interface for JDBC3.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Statement or one of it's parents * org.postgresql.jdbc3.AbstractJdbc3Statement or one of it's parents
......
...@@ -118,7 +118,8 @@ public class LargeObjectManager ...@@ -118,7 +118,8 @@ public class LargeObjectManager
fp.addFunctions(res); fp.addFunctions(res);
res.close(); res.close();
if (Driver.logDebug) Driver.debug("Large Object initialised"); if (Driver.logDebug)
Driver.debug("Large Object initialised");
} }
/* /*
......
...@@ -23,7 +23,7 @@ public class CallableStmtTest extends TestCase ...@@ -23,7 +23,7 @@ public class CallableStmtTest extends TestCase
con = TestUtil.openDB(); con = TestUtil.openDB();
Statement stmt = con.createStatement (); Statement stmt = con.createStatement ();
stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getString (varchar) " + stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getString (varchar) " +
"RETURNS varchar AS ' DECLARE inString alias for $1; begin "+ "RETURNS varchar AS ' DECLARE inString alias for $1; begin " +
"return ''bob''; end; ' LANGUAGE 'plpgsql';"); "return ''bob''; end; ' LANGUAGE 'plpgsql';");
stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getDouble (float) " + stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getDouble (float) " +
"RETURNS float AS ' DECLARE inString alias for $1; begin " + "RETURNS float AS ' DECLARE inString alias for $1; begin " +
...@@ -54,7 +54,8 @@ public class CallableStmtTest extends TestCase ...@@ -54,7 +54,8 @@ public class CallableStmtTest extends TestCase
//testGetString (); //testGetString ();
//} //}
public void testGetDouble () throws Throwable { public void testGetDouble () throws Throwable
{
// System.out.println ("Testing CallableStmt Types.DOUBLE"); // System.out.println ("Testing CallableStmt Types.DOUBLE");
CallableStatement call = con.prepareCall (func + pkgName + "getDouble (?) }"); CallableStatement call = con.prepareCall (func + pkgName + "getDouble (?) }");
call.setDouble (2, (double)3.04); call.setDouble (2, (double)3.04);
...@@ -64,7 +65,8 @@ public class CallableStmtTest extends TestCase ...@@ -64,7 +65,8 @@ public class CallableStmtTest extends TestCase
assertTrue ("correct return from getString ()", result == 42.42); assertTrue ("correct return from getString ()", result == 42.42);
} }
public void testGetInt () throws Throwable { public void testGetInt () throws Throwable
{
// System.out.println ("Testing CallableStmt Types.INTEGER"); // System.out.println ("Testing CallableStmt Types.INTEGER");
CallableStatement call = con.prepareCall (func + pkgName + "getInt (?) }"); CallableStatement call = con.prepareCall (func + pkgName + "getInt (?) }");
call.setInt (2, 4); call.setInt (2, 4);
...@@ -74,7 +76,8 @@ public class CallableStmtTest extends TestCase ...@@ -74,7 +76,8 @@ public class CallableStmtTest extends TestCase
assertTrue ("correct return from getString ()", result == 42); assertTrue ("correct return from getString ()", result == 42);
} }
public void testGetNumeric () throws Throwable { public void testGetNumeric () throws Throwable
{
// System.out.println ("Testing CallableStmt Types.NUMERIC"); // System.out.println ("Testing CallableStmt Types.NUMERIC");
CallableStatement call = con.prepareCall (func + pkgName + "getNumeric (?) }"); CallableStatement call = con.prepareCall (func + pkgName + "getNumeric (?) }");
call.setBigDecimal (2, new java.math.BigDecimal(4)); call.setBigDecimal (2, new java.math.BigDecimal(4));
...@@ -85,7 +88,8 @@ public class CallableStmtTest extends TestCase ...@@ -85,7 +88,8 @@ public class CallableStmtTest extends TestCase
result.equals (new java.math.BigDecimal(42))); result.equals (new java.math.BigDecimal(42)));
} }
public void testGetString () throws Throwable { public void testGetString () throws Throwable
{
// System.out.println ("Testing CallableStmt Types.VARCHAR"); // System.out.println ("Testing CallableStmt Types.VARCHAR");
CallableStatement call = con.prepareCall (func + pkgName + "getString (?) }"); CallableStatement call = con.prepareCall (func + pkgName + "getString (?) }");
call.setString (2, "foo"); call.setString (2, "foo");
...@@ -96,20 +100,25 @@ public class CallableStmtTest extends TestCase ...@@ -96,20 +100,25 @@ public class CallableStmtTest extends TestCase
} }
public void testBadStmt () throws Throwable { public void testBadStmt () throws Throwable
{
tryOneBadStmt ("{ ?= " + pkgName + "getString (?) }"); tryOneBadStmt ("{ ?= " + pkgName + "getString (?) }");
tryOneBadStmt ("{ ?= call getString (?) "); tryOneBadStmt ("{ ?= call getString (?) ");
tryOneBadStmt ("{ = ? call getString (?); }"); tryOneBadStmt ("{ = ? call getString (?); }");
} }
protected void tryOneBadStmt (String sql) throws Throwable { protected void tryOneBadStmt (String sql) throws Throwable
{
boolean wasCaught = false; boolean wasCaught = false;
try { try
{
CallableStatement call = con.prepareCall (sql); CallableStatement call = con.prepareCall (sql);
} catch (SQLException e) { }
catch (SQLException e)
{
wasCaught = true; // good -> this statement was missing something wasCaught = true; // good -> this statement was missing something
} }
assertTrue ("bad statment ('"+sql+"')was not caught", wasCaught); assertTrue ("bad statment ('" + sql + "')was not caught", wasCaught);
} }
} }
...@@ -9,7 +9,7 @@ import java.sql.*; ...@@ -9,7 +9,7 @@ import java.sql.*;
* *
* PS: Do you know how difficult it is to type on a train? ;-) * PS: Do you know how difficult it is to type on a train? ;-)
* *
* $Id: DatabaseMetaDataTest.java,v 1.12 2002/08/23 20:45:49 barry Exp $ * $Id: DatabaseMetaDataTest.java,v 1.13 2002/09/06 21:23:06 momjian Exp $
*/ */
public class DatabaseMetaDataTest extends TestCase public class DatabaseMetaDataTest extends TestCase
...@@ -248,7 +248,7 @@ public class DatabaseMetaDataTest extends TestCase ...@@ -248,7 +248,7 @@ public class DatabaseMetaDataTest extends TestCase
ResultSet rs = dbmd.getCrossReference(null, "", "vv", null, "", "ww" ); ResultSet rs = dbmd.getCrossReference(null, "", "vv", null, "", "ww" );
for (int j=1; rs.next(); j++ ) for (int j = 1; rs.next(); j++ )
{ {
String pkTableName = rs.getString( "PKTABLE_NAME" ); String pkTableName = rs.getString( "PKTABLE_NAME" );
...@@ -291,8 +291,8 @@ public class DatabaseMetaDataTest extends TestCase ...@@ -291,8 +291,8 @@ public class DatabaseMetaDataTest extends TestCase
TestUtil.createTable( con1, "people", "id int4 primary key, name text" ); TestUtil.createTable( con1, "people", "id int4 primary key, name text" );
TestUtil.createTable( con1, "policy", "id int4 primary key, name text" ); TestUtil.createTable( con1, "policy", "id int4 primary key, name text" );
TestUtil.createTable( con1, "users", "id int4 primary key, people_id int4, policy_id int4,"+ TestUtil.createTable( con1, "users", "id int4 primary key, people_id int4, policy_id int4," +
"CONSTRAINT people FOREIGN KEY (people_id) references people(id),"+ "CONSTRAINT people FOREIGN KEY (people_id) references people(id)," +
"constraint policy FOREIGN KEY (policy_id) references policy(id)" ); "constraint policy FOREIGN KEY (policy_id) references policy(id)" );
...@@ -324,7 +324,7 @@ public class DatabaseMetaDataTest extends TestCase ...@@ -324,7 +324,7 @@ public class DatabaseMetaDataTest extends TestCase
} }
assertTrue ( j== 2 ); assertTrue ( j == 2 );
rs = dbmd.getExportedKeys( null, "", "people" ); rs = dbmd.getExportedKeys( null, "", "people" );
......
...@@ -6,7 +6,7 @@ import java.sql.*; ...@@ -6,7 +6,7 @@ import java.sql.*;
import java.math.BigDecimal; import java.math.BigDecimal;
/* /*
* $Id: JBuilderTest.java,v 1.6 2002/08/14 20:35:40 barry Exp $ * $Id: JBuilderTest.java,v 1.7 2002/09/06 21:23:06 momjian Exp $
* *
* Some simple tests to check that the required components needed for JBuilder * Some simple tests to check that the required components needed for JBuilder
* stay working * stay working
......
...@@ -5,7 +5,7 @@ import junit.framework.TestCase; ...@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import java.sql.*; import java.sql.*;
/* /*
* $Id: MiscTest.java,v 1.7 2002/08/14 20:35:40 barry Exp $ * $Id: MiscTest.java,v 1.8 2002/09/06 21:23:06 momjian Exp $
* *
* Some simple tests based on problems reported by users. Hopefully these will * Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-) * help prevent previous problems from re-occuring ;-)
...@@ -66,13 +66,14 @@ public class MiscTest extends TestCase ...@@ -66,13 +66,14 @@ public class MiscTest extends TestCase
con.commit(); con.commit();
} }
catch ( Exception ex ) catch ( Exception ex )
{ {}
}
try try
{ {
con.commit(); con.commit();
con.close(); con.close();
}catch ( Exception ex) {} }
catch ( Exception ex)
{}
} }
public void xtestLocking() public void xtestLocking()
......
...@@ -5,7 +5,7 @@ import junit.framework.TestCase; ...@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import java.sql.*; import java.sql.*;
/* /*
* $Id: TimestampTest.java,v 1.8 2002/08/14 20:35:40 barry Exp $ * $Id: TimestampTest.java,v 1.9 2002/09/06 21:23:06 momjian Exp $
* *
* Test get/setTimestamp for both timestamp with time zone and * Test get/setTimestamp for both timestamp with time zone and
* timestamp without time zone datatypes * timestamp without time zone datatypes
...@@ -49,9 +49,9 @@ public class TimestampTest extends TestCase ...@@ -49,9 +49,9 @@ public class TimestampTest extends TestCase
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
//Insert the three timestamp values in raw pg format //Insert the three timestamp values in raw pg format
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE,"'" + TS1WTZ_PGFORMAT + "'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE, "'" + TS1WTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE,"'" + TS2WTZ_PGFORMAT + "'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE, "'" + TS2WTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE,"'" + TS3WTZ_PGFORMAT + "'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE, "'" + TS3WTZ_PGFORMAT + "'")));
// Fall through helper // Fall through helper
timestampTestWTZ(); timestampTestWTZ();
...@@ -114,9 +114,9 @@ public class TimestampTest extends TestCase ...@@ -114,9 +114,9 @@ public class TimestampTest extends TestCase
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
//Insert the three timestamp values in raw pg format //Insert the three timestamp values in raw pg format
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE,"'" + TS1WOTZ_PGFORMAT + "'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS1WOTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE,"'" + TS2WOTZ_PGFORMAT + "'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS2WOTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE,"'" + TS3WOTZ_PGFORMAT + "'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS3WOTZ_PGFORMAT + "'")));
// Fall through helper // Fall through helper
timestampTestWOTZ(); timestampTestWOTZ();
...@@ -238,7 +238,8 @@ public class TimestampTest extends TestCase ...@@ -238,7 +238,8 @@ public class TimestampTest extends TestCase
{ {
java.sql.Timestamp l_return = null; java.sql.Timestamp l_return = null;
java.text.DateFormat l_df; java.text.DateFormat l_df;
try { try
{
String l_ts; String l_ts;
l_ts = TestUtil.fix(y, 4) + "-" + l_ts = TestUtil.fix(y, 4) + "-" +
TestUtil.fix(m, 2) + "-" + TestUtil.fix(m, 2) + "-" +
...@@ -247,16 +248,21 @@ public class TimestampTest extends TestCase ...@@ -247,16 +248,21 @@ public class TimestampTest extends TestCase
TestUtil.fix(mn, 2) + ":" + TestUtil.fix(mn, 2) + ":" +
TestUtil.fix(se, 2) + " "; TestUtil.fix(se, 2) + " ";
if (tz == null) { if (tz == null)
{
l_df = new java.text.SimpleDateFormat("y-M-d H:m:s"); l_df = new java.text.SimpleDateFormat("y-M-d H:m:s");
} else { }
else
{
l_ts = l_ts + tz; l_ts = l_ts + tz;
l_df = new java.text.SimpleDateFormat("y-M-d H:m:s z"); l_df = new java.text.SimpleDateFormat("y-M-d H:m:s z");
} }
java.util.Date l_date = l_df.parse(l_ts); java.util.Date l_date = l_df.parse(l_ts);
l_return = new java.sql.Timestamp(l_date.getTime()); l_return = new java.sql.Timestamp(l_date.getTime());
l_return.setNanos(f); l_return.setNanos(f);
} catch (Exception ex) { }
catch (Exception ex)
{
fail(ex.getMessage()); fail(ex.getMessage());
} }
return l_return; return l_return;
......
...@@ -26,8 +26,8 @@ public class UpdateableResultTest extends TestCase ...@@ -26,8 +26,8 @@ public class UpdateableResultTest extends TestCase
try try
{ {
Connection con = TestUtil.openDB(); Connection con = TestUtil.openDB();
TestUtil.createTable(con, "updateable","id int primary key, name text, notselected text"); TestUtil.createTable(con, "updateable", "id int primary key, name text, notselected text");
TestUtil.createTable(con, "second","id1 int primary key, name1 text"); TestUtil.createTable(con, "second", "id1 int primary key, name1 text");
// put some dummy data into second // put some dummy data into second
Statement st2 = con.createStatement(); Statement st2 = con.createStatement();
...@@ -44,8 +44,8 @@ public class UpdateableResultTest extends TestCase ...@@ -44,8 +44,8 @@ public class UpdateableResultTest extends TestCase
rs.insertRow(); rs.insertRow();
rs.first(); rs.first();
rs.updateInt( "id",2 ); rs.updateInt( "id", 2 );
rs.updateString( "name","dave" ); rs.updateString( "name", "dave" );
rs.updateRow(); rs.updateRow();
assertTrue( rs.getInt("id") == 2 ); assertTrue( rs.getInt("id") == 2 );
...@@ -54,7 +54,7 @@ public class UpdateableResultTest extends TestCase ...@@ -54,7 +54,7 @@ public class UpdateableResultTest extends TestCase
rs.deleteRow(); rs.deleteRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt("id",3); rs.updateInt("id", 3);
rs.updateString("name", "paul"); rs.updateString("name", "paul");
rs.insertRow(); rs.insertRow();
...@@ -69,17 +69,18 @@ public class UpdateableResultTest extends TestCase ...@@ -69,17 +69,18 @@ public class UpdateableResultTest extends TestCase
rs = st.executeQuery("select id1, id, name, name1 from updateable, second" ); rs = st.executeQuery("select id1, id, name, name1 from updateable, second" );
try try
{ {
while( rs.next() ) while ( rs.next() )
{ {
rs.updateInt( "id",2 ); rs.updateInt( "id", 2 );
rs.updateString( "name","dave" ); rs.updateString( "name", "dave" );
rs.updateRow(); rs.updateRow();
} }
assertTrue( "should not get here, update should fail", false ); assertTrue( "should not get here, update should fail", false );
} }
catch (SQLException ex){} catch (SQLException ex)
{}
try try
{ {
...@@ -115,14 +116,14 @@ public class UpdateableResultTest extends TestCase ...@@ -115,14 +116,14 @@ public class UpdateableResultTest extends TestCase
} }
} }
catch(SQLException ex) catch (SQLException ex)
{ {
fail(ex.getMessage()); fail(ex.getMessage());
} }
st.close(); st.close();
TestUtil.dropTable( con,"updateable" ); TestUtil.dropTable( con, "updateable" );
TestUtil.closeDB( con ); TestUtil.closeDB( con );
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -15,16 +15,18 @@ import java.sql.*; ...@@ -15,16 +15,18 @@ import java.sql.*;
* tests. * tests.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public abstract class BaseDataSourceTest extends TestCase { public abstract class BaseDataSourceTest extends TestCase
{
protected Connection con; protected Connection con;
protected BaseDataSource bds; protected BaseDataSource bds;
/** /**
* Constructor required by JUnit * Constructor required by JUnit
*/ */
public BaseDataSourceTest(String name) { public BaseDataSourceTest(String name)
{
super(name); super(name);
} }
...@@ -32,7 +34,8 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -32,7 +34,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* Creates a test table using a standard connection (not from a * Creates a test table using a standard connection (not from a
* DataSource). * DataSource).
*/ */
protected void setUp() throws Exception { protected void setUp() throws Exception
{
con = JDBC2Tests.openDB(); con = JDBC2Tests.openDB();
JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)"); JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
...@@ -45,7 +48,8 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -45,7 +48,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* Removes the test table using a standard connection (not from * Removes the test table using a standard connection (not from
* a DataSource) * a DataSource)
*/ */
protected void tearDown() throws Exception { protected void tearDown() throws Exception
{
con = JDBC2Tests.openDB(); con = JDBC2Tests.openDB();
JDBC2Tests.dropTable(con, "poolingtest"); JDBC2Tests.dropTable(con, "poolingtest");
JDBC2Tests.closeDB(con); JDBC2Tests.closeDB(con);
...@@ -54,7 +58,8 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -54,7 +58,8 @@ public abstract class BaseDataSourceTest extends TestCase {
/** /**
* Gets a connection from the current BaseDataSource * Gets a connection from the current BaseDataSource
*/ */
protected Connection getDataSourceConnection() throws SQLException { protected Connection getDataSourceConnection() throws SQLException
{
initializeDataSource(); initializeDataSource();
return bds.getConnection(); return bds.getConnection();
} }
...@@ -69,7 +74,8 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -69,7 +74,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* Test to make sure you can instantiate and configure the * Test to make sure you can instantiate and configure the
* appropriate DataSource * appropriate DataSource
*/ */
public void testCreateDataSource() { public void testCreateDataSource()
{
initializeDataSource(); initializeDataSource();
} }
...@@ -77,11 +83,15 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -77,11 +83,15 @@ public abstract class BaseDataSourceTest extends TestCase {
* Test to make sure you can get a connection from the DataSource, * Test to make sure you can get a connection from the DataSource,
* which in turn means the DataSource was able to open it. * which in turn means the DataSource was able to open it.
*/ */
public void testGetConnection() { public void testGetConnection()
try { {
try
{
con = getDataSourceConnection(); con = getDataSourceConnection();
con.close(); con.close();
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -90,26 +100,35 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -90,26 +100,35 @@ public abstract class BaseDataSourceTest extends TestCase {
* A simple test to make sure you can execute SQL using the * A simple test to make sure you can execute SQL using the
* Connection from the DataSource * Connection from the DataSource
*/ */
public void testUseConnection() { public void testUseConnection()
try { {
try
{
con = getDataSourceConnection(); con = getDataSourceConnection();
Statement st = con.createStatement(); Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM poolingtest"); ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM poolingtest");
if(rs.next()) { if (rs.next())
{
int count = rs.getInt(1); int count = rs.getInt(1);
if(rs.next()) { if (rs.next())
{
fail("Should only have one row in SELECT COUNT result set"); fail("Should only have one row in SELECT COUNT result set");
} }
if(count != 2) { if (count != 2)
fail("Count returned "+count+" expecting 2"); {
fail("Count returned " + count + " expecting 2");
}
} }
} else { else
{
fail("Should have one row in SELECT COUNT result set"); fail("Should have one row in SELECT COUNT result set");
} }
rs.close(); rs.close();
st.close(); st.close();
con.close(); con.close();
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -118,13 +137,17 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -118,13 +137,17 @@ public abstract class BaseDataSourceTest extends TestCase {
* A test to make sure you can execute DDL SQL using the * A test to make sure you can execute DDL SQL using the
* Connection from the DataSource. * Connection from the DataSource.
*/ */
public void testDdlOverConnection() { public void testDdlOverConnection()
try { {
try
{
con = getDataSourceConnection(); con = getDataSourceConnection();
JDBC2Tests.dropTable(con, "poolingtest"); JDBC2Tests.dropTable(con, "poolingtest");
JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)"); JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
con.close(); con.close();
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -134,8 +157,10 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -134,8 +157,10 @@ public abstract class BaseDataSourceTest extends TestCase {
* current DataSource. Obviously need to be overridden in the case * current DataSource. Obviously need to be overridden in the case
* of a pooling Datasource. * of a pooling Datasource.
*/ */
public void testNotPooledConnection() { public void testNotPooledConnection()
try { {
try
{
con = getDataSourceConnection(); con = getDataSourceConnection();
String name = con.toString(); String name = con.toString();
con.close(); con.close();
...@@ -143,7 +168,9 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -143,7 +168,9 @@ public abstract class BaseDataSourceTest extends TestCase {
String name2 = con.toString(); String name2 = con.toString();
con.close(); con.close();
assertTrue(!name.equals(name2)); assertTrue(!name.equals(name2));
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -154,7 +181,8 @@ public abstract class BaseDataSourceTest extends TestCase { ...@@ -154,7 +181,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* should ideally test both Serializable and Referenceable * should ideally test both Serializable and Referenceable
* mechanisms. Will probably be multiple tests when implemented. * mechanisms. Will probably be multiple tests when implemented.
*/ */
public void testJndi() { public void testJndi()
{
// TODO: Put the DS in JNDI, retrieve it, and try some of this stuff again // TODO: Put the DS in JNDI, retrieve it, and try some of this stuff again
} }
} }
...@@ -11,27 +11,34 @@ import java.sql.*; ...@@ -11,27 +11,34 @@ import java.sql.*;
* interface to the PooledConnection is through the CPDS. * interface to the PooledConnection is through the CPDS.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class ConnectionPoolTest extends BaseDataSourceTest { public class ConnectionPoolTest extends BaseDataSourceTest
{
/** /**
* Constructor required by JUnit * Constructor required by JUnit
*/ */
public ConnectionPoolTest(String name) { public ConnectionPoolTest(String name)
{
super(name); super(name);
} }
/** /**
* Creates and configures a ConnectionPool * Creates and configures a ConnectionPool
*/ */
protected void initializeDataSource() { protected void initializeDataSource()
if(bds == null) { {
if (bds == null)
{
bds = new ConnectionPool(); bds = new ConnectionPool();
String db = JDBC2Tests.getURL(); String db = JDBC2Tests.getURL();
if(db.indexOf('/') > -1) { if (db.indexOf('/') > -1)
db = db.substring(db.lastIndexOf('/')+1); {
} else if(db.indexOf(':') > -1) { db = db.substring(db.lastIndexOf('/') + 1);
db = db.substring(db.lastIndexOf(':')+1); }
else if (db.indexOf(':') > -1)
{
db = db.substring(db.lastIndexOf(':') + 1);
} }
bds.setDatabaseName(db); bds.setDatabaseName(db);
bds.setUser(JDBC2Tests.getUser()); bds.setUser(JDBC2Tests.getUser());
...@@ -44,7 +51,8 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -44,7 +51,8 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* order to test the middleware/server interface, we need to deal * order to test the middleware/server interface, we need to deal
* with PooledConnections. Some tests use each. * with PooledConnections. Some tests use each.
*/ */
protected PooledConnection getPooledConnection() throws SQLException { protected PooledConnection getPooledConnection() throws SQLException
{
initializeDataSource(); initializeDataSource();
return ((ConnectionPool)bds).getPooledConnection(); return ((ConnectionPool)bds).getPooledConnection();
} }
...@@ -57,22 +65,29 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -57,22 +65,29 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* would never by closed. Probably not a disaster during testing, but * would never by closed. Probably not a disaster during testing, but
* you never know. * you never know.
*/ */
protected Connection getDataSourceConnection() throws SQLException { protected Connection getDataSourceConnection() throws SQLException
{
initializeDataSource(); initializeDataSource();
final PooledConnection pc = getPooledConnection(); final PooledConnection pc = getPooledConnection();
// Since the pooled connection won't be reused in these basic tests, close it when the connection is closed // Since the pooled connection won't be reused in these basic tests, close it when the connection is closed
pc.addConnectionEventListener(new ConnectionEventListener() { pc.addConnectionEventListener(new ConnectionEventListener()
public void connectionClosed(ConnectionEvent event) { {
try { public void connectionClosed(ConnectionEvent event)
{
try
{
pc.close(); pc.close();
} catch (SQLException e) { }
fail("Unable to close PooledConnection: "+e); catch (SQLException e)
{
fail("Unable to close PooledConnection: " + e);
} }
} }
public void connectionErrorOccurred(ConnectionEvent event) { public void connectionErrorOccurred(ConnectionEvent event)
{}
} }
}); );
return pc.getConnection(); return pc.getConnection();
} }
...@@ -82,8 +97,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -82,8 +97,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* physical connection. Depends on the implementation of toString * physical connection. Depends on the implementation of toString
* for the connection handle. * for the connection handle.
*/ */
public void testPoolReuse() { public void testPoolReuse()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
con = pc.getConnection(); con = pc.getConnection();
String name = con.toString(); String name = con.toString();
...@@ -93,7 +110,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -93,7 +110,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con.close(); con.close();
pc.close(); pc.close();
assertTrue("Physical connection doesn't appear to be reused across PooledConnection wrappers", name.equals(name2)); assertTrue("Physical connection doesn't appear to be reused across PooledConnection wrappers", name.equals(name2));
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -104,22 +123,32 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -104,22 +123,32 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* out is closed. See JDBC 2.0 Optional Package spec section * out is closed. See JDBC 2.0 Optional Package spec section
* 6.2.3 * 6.2.3
*/ */
public void testPoolCloseOldWrapper() { public void testPoolCloseOldWrapper()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
con = pc.getConnection(); con = pc.getConnection();
Connection con2 = pc.getConnection(); Connection con2 = pc.getConnection();
try { try
{
con.createStatement(); con.createStatement();
fail("Original connection wrapper should be closed when new connection wrapper is generated"); fail("Original connection wrapper should be closed when new connection wrapper is generated");
} catch(SQLException e) {} }
try { catch (SQLException e)
{}
try
{
con.close(); con.close();
fail("Original connection wrapper should be closed when new connection wrapper is generated"); fail("Original connection wrapper should be closed when new connection wrapper is generated");
} catch(SQLException e) {} }
catch (SQLException e)
{}
con2.close(); con2.close();
pc.close(); pc.close();
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -130,15 +159,19 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -130,15 +159,19 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* the same physical connection. See JDBC 2.0 Optional Pacakge spec * the same physical connection. See JDBC 2.0 Optional Pacakge spec
* section 6.2.2 * section 6.2.2
*/ */
public void testPoolNewWrapper() { public void testPoolNewWrapper()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
con = pc.getConnection(); con = pc.getConnection();
Connection con2 = pc.getConnection(); Connection con2 = pc.getConnection();
con2.close(); con2.close();
pc.close(); pc.close();
assertTrue("Two calls to PooledConnection.getConnection should not return the same connection wrapper", con != con2); assertTrue("Two calls to PooledConnection.getConnection should not return the same connection wrapper", con != con2);
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -148,8 +181,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -148,8 +181,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* connection handle is closed. Also checks that events are not * connection handle is closed. Also checks that events are not
* fired after a given handle has been closed once. * fired after a given handle has been closed once.
*/ */
public void testCloseEvent() { public void testCloseEvent()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
CountClose cc = new CountClose(); CountClose cc = new CountClose();
pc.addConnectionEventListener(cc); pc.addConnectionEventListener(cc);
...@@ -165,14 +200,19 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -165,14 +200,19 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con.close(); con.close();
assertTrue(cc.getCount() == 2); assertTrue(cc.getCount() == 2);
assertTrue(cc.getErrorCount() == 0); assertTrue(cc.getErrorCount() == 0);
try { try
{
con.close(); con.close();
fail("Should not be able to close a connection wrapper twice"); fail("Should not be able to close a connection wrapper twice");
} catch (SQLException e) {} }
catch (SQLException e)
{}
assertTrue(cc.getCount() == 2); assertTrue(cc.getCount() == 2);
assertTrue(cc.getErrorCount() == 0); assertTrue(cc.getErrorCount() == 0);
pc.close(); pc.close();
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -181,8 +221,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -181,8 +221,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* Makes sure that close events are not fired after a listener has * Makes sure that close events are not fired after a listener has
* been removed. * been removed.
*/ */
public void testNoCloseEvent() { public void testNoCloseEvent()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
CountClose cc = new CountClose(); CountClose cc = new CountClose();
pc.addConnectionEventListener(cc); pc.addConnectionEventListener(cc);
...@@ -199,7 +241,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -199,7 +241,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con.close(); con.close();
assertTrue(cc.getCount() == 1); assertTrue(cc.getCount() == 1);
assertTrue(cc.getErrorCount() == 0); assertTrue(cc.getErrorCount() == 0);
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -209,8 +253,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -209,8 +253,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* events. Sometimes this causes a ConcurrentModificationException * events. Sometimes this causes a ConcurrentModificationException
* or something. * or something.
*/ */
public void testInlineCloseEvent() { public void testInlineCloseEvent()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
RemoveClose rc1 = new RemoveClose(); RemoveClose rc1 = new RemoveClose();
RemoveClose rc2 = new RemoveClose(); RemoveClose rc2 = new RemoveClose();
...@@ -222,7 +268,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -222,7 +268,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con.close(); con.close();
con = pc.getConnection(); con = pc.getConnection();
con.close(); con.close();
} catch (Exception e) { }
catch (Exception e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -233,8 +281,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -233,8 +281,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* being opened for the same PooledConnection. See JDBC 2.0 * being opened for the same PooledConnection. See JDBC 2.0
* Optional Package spec section 6.3 * Optional Package spec section 6.3
*/ */
public void testAutomaticCloseEvent() { public void testAutomaticCloseEvent()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
CountClose cc = new CountClose(); CountClose cc = new CountClose();
pc.addConnectionEventListener(cc); pc.addConnectionEventListener(cc);
...@@ -256,7 +306,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -256,7 +306,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
assertTrue(cc.getCount() == 2); assertTrue(cc.getCount() == 2);
assertTrue(cc.getErrorCount() == 0); assertTrue(cc.getErrorCount() == 0);
pc.close(); pc.close();
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -266,8 +318,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -266,8 +318,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* you'd expect. Checks the usual case, as well as automatic * you'd expect. Checks the usual case, as well as automatic
* closure when a new handle is opened on the same physical connection. * closure when a new handle is opened on the same physical connection.
*/ */
public void testIsClosed() { public void testIsClosed()
try { {
try
{
PooledConnection pc = getPooledConnection(); PooledConnection pc = getPooledConnection();
Connection con = pc.getConnection(); Connection con = pc.getConnection();
assertTrue(!con.isClosed()); assertTrue(!con.isClosed());
...@@ -280,7 +334,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -280,7 +334,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con2.close(); con2.close();
assertTrue(con.isClosed()); assertTrue(con.isClosed());
pc.close(); pc.close();
} catch (SQLException e) { }
catch (SQLException e)
{
fail(e.getMessage()); fail(e.getMessage());
} }
} }
...@@ -288,12 +344,15 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -288,12 +344,15 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
/** /**
* Helper class to remove a listener during event dispatching. * Helper class to remove a listener during event dispatching.
*/ */
private class RemoveClose implements ConnectionEventListener { private class RemoveClose implements ConnectionEventListener
public void connectionClosed(ConnectionEvent event) { {
public void connectionClosed(ConnectionEvent event)
{
((PooledConnection)event.getSource()).removeConnectionEventListener(this); ((PooledConnection)event.getSource()).removeConnectionEventListener(this);
} }
public void connectionErrorOccurred(ConnectionEvent event) { public void connectionErrorOccurred(ConnectionEvent event)
{
((PooledConnection)event.getSource()).removeConnectionEventListener(this); ((PooledConnection)event.getSource()).removeConnectionEventListener(this);
} }
} }
...@@ -302,25 +361,31 @@ public class ConnectionPoolTest extends BaseDataSourceTest { ...@@ -302,25 +361,31 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* Helper class that implements the event listener interface, and * Helper class that implements the event listener interface, and
* counts the number of events it sees. * counts the number of events it sees.
*/ */
private class CountClose implements ConnectionEventListener { private class CountClose implements ConnectionEventListener
{
private int count = 0, errorCount = 0; private int count = 0, errorCount = 0;
public void connectionClosed(ConnectionEvent event) { public void connectionClosed(ConnectionEvent event)
{
count++; count++;
} }
public void connectionErrorOccurred(ConnectionEvent event) { public void connectionErrorOccurred(ConnectionEvent event)
{
errorCount++; errorCount++;
} }
public int getCount() { public int getCount()
{
return count; return count;
} }
public int getErrorCount() { public int getErrorCount()
{
return errorCount; return errorCount;
} }
public void clear() { public void clear()
{
count = errorCount = 0; count = errorCount = 0;
} }
} }
......
...@@ -8,14 +8,16 @@ import junit.framework.TestSuite; ...@@ -8,14 +8,16 @@ import junit.framework.TestSuite;
* PooledConnection implementations. * PooledConnection implementations.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class OptionalTestSuite extends TestSuite { public class OptionalTestSuite extends TestSuite
{
/** /**
* Gets the test suite for the entire JDBC 2.0 Optional Package * Gets the test suite for the entire JDBC 2.0 Optional Package
* implementation. * implementation.
*/ */
public static TestSuite suite() { public static TestSuite suite()
{
TestSuite suite = new TestSuite(); TestSuite suite = new TestSuite();
suite.addTestSuite(SimpleDataSourceTest.class); suite.addTestSuite(SimpleDataSourceTest.class);
suite.addTestSuite(ConnectionPoolTest.class); suite.addTestSuite(ConnectionPoolTest.class);
......
...@@ -8,27 +8,34 @@ import org.postgresql.jdbc2.optional.SimpleDataSource; ...@@ -8,27 +8,34 @@ import org.postgresql.jdbc2.optional.SimpleDataSource;
* configuration logic. * configuration logic.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
public class SimpleDataSourceTest extends BaseDataSourceTest { public class SimpleDataSourceTest extends BaseDataSourceTest
{
/** /**
* Constructor required by JUnit * Constructor required by JUnit
*/ */
public SimpleDataSourceTest(String name) { public SimpleDataSourceTest(String name)
{
super(name); super(name);
} }
/** /**
* Creates and configures a new SimpleDataSource. * Creates and configures a new SimpleDataSource.
*/ */
protected void initializeDataSource() { protected void initializeDataSource()
if(bds == null) { {
if (bds == null)
{
bds = new SimpleDataSource(); bds = new SimpleDataSource();
String db = JDBC2Tests.getURL(); String db = JDBC2Tests.getURL();
if(db.indexOf('/') > -1) { if (db.indexOf('/') > -1)
db = db.substring(db.lastIndexOf('/')+1); {
} else if(db.indexOf(':') > -1) { db = db.substring(db.lastIndexOf('/') + 1);
db = db.substring(db.lastIndexOf(':')+1); }
else if (db.indexOf(':') > -1)
{
db = db.substring(db.lastIndexOf(':') + 1);
} }
bds.setDatabaseName(db); bds.setDatabaseName(db);
bds.setUser(JDBC2Tests.getUser()); bds.setUser(JDBC2Tests.getUser());
......
...@@ -5,7 +5,7 @@ import java.sql.*; ...@@ -5,7 +5,7 @@ import java.sql.*;
/* /*
* Converts to and from the postgresql bytea datatype used by the backend. * Converts to and from the postgresql bytea datatype used by the backend.
* *
* $Id: PGbytea.java,v 1.5 2002/08/16 17:51:38 barry Exp $ * $Id: PGbytea.java,v 1.6 2002/09/06 21:23:06 momjian Exp $
*/ */
public class PGbytea public class PGbytea
......
...@@ -78,6 +78,7 @@ public class PGtokenizer ...@@ -78,6 +78,7 @@ public class PGtokenizer
// Don't forget the last token ;-) // Don't forget the last token ;-)
if (s < string.length()) if (s < string.length())
tokens.addElement(string.substring(s)); tokens.addElement(string.substring(s));
......
...@@ -129,14 +129,16 @@ public class Serialize ...@@ -129,14 +129,16 @@ public class Serialize
try try
{ {
conn = c; conn = c;
if (Driver.logDebug) Driver.debug("Serialize: initializing instance for type: " + type); if (Driver.logDebug)
Driver.debug("Serialize: initializing instance for type: " + type);
tableName = toPostgreSQL(type); tableName = toPostgreSQL(type);
className = type; className = type;
ourClass = Class.forName(className); ourClass = Class.forName(className);
} }
catch (ClassNotFoundException cnfe) catch (ClassNotFoundException cnfe)
{ {
if (Driver.logDebug) Driver.debug("Serialize: " + className + " java class not found"); if (Driver.logDebug)
Driver.debug("Serialize: " + className + " java class not found");
throw new PSQLException("postgresql.serial.noclass", type); throw new PSQLException("postgresql.serial.noclass", type);
} }
...@@ -148,14 +150,16 @@ public class Serialize ...@@ -148,14 +150,16 @@ public class Serialize
if (rs.next()) if (rs.next())
{ {
status = true; status = true;
if (Driver.logDebug) Driver.debug("Serialize: " + tableName + " table found"); if (Driver.logDebug)
Driver.debug("Serialize: " + tableName + " table found");
} }
rs.close(); rs.close();
} }
// This should never occur, as org.postgresql has it's own internal checks // This should never occur, as org.postgresql has it's own internal checks
if (!status) if (!status)
{ {
if (Driver.logDebug) Driver.debug("Serialize: " + tableName + " table not found"); if (Driver.logDebug)
Driver.debug("Serialize: " + tableName + " table not found");
throw new PSQLException("postgresql.serial.table", type); throw new PSQLException("postgresql.serial.table", type);
} }
// Finally cache the fields within the table // Finally cache the fields within the table
...@@ -187,9 +191,11 @@ public class Serialize ...@@ -187,9 +191,11 @@ public class Serialize
{ {
try try
{ {
if (Driver.logDebug) Driver.debug("Serialize.fetch: " + "attempting to instantiate object of type: " + ourClass.getName() ); if (Driver.logDebug)
Driver.debug("Serialize.fetch: " + "attempting to instantiate object of type: " + ourClass.getName() );
Object obj = ourClass.newInstance(); Object obj = ourClass.newInstance();
if (Driver.logDebug) Driver.debug("Serialize.fetch: " + "instantiated object of type: " + ourClass.getName() ); if (Driver.logDebug)
Driver.debug("Serialize.fetch: " + "instantiated object of type: " + ourClass.getName() );
// NB: we use java.lang.reflect here to prevent confusion with // NB: we use java.lang.reflect here to prevent confusion with
// the org.postgresql.Field // the org.postgresql.Field
...@@ -220,7 +226,8 @@ public class Serialize ...@@ -220,7 +226,8 @@ public class Serialize
sb.append(" where oid="); sb.append(" where oid=");
sb.append(oid); sb.append(oid);
if (Driver.logDebug) Driver.debug("Serialize.fetch: " + sb.toString()); if (Driver.logDebug)
Driver.debug("Serialize.fetch: " + sb.toString());
ResultSet rs = ((org.postgresql.jdbc1.AbstractJdbc1Connection)conn).ExecSQL(sb.toString()); ResultSet rs = ((org.postgresql.jdbc1.AbstractJdbc1Connection)conn).ExecSQL(sb.toString());
if (rs != null) if (rs != null)
...@@ -389,7 +396,8 @@ public class Serialize ...@@ -389,7 +396,8 @@ public class Serialize
sb.append(')'); sb.append(')');
} }
if (Driver.logDebug) Driver.debug("Serialize.store: " + sb.toString() ); if (Driver.logDebug)
Driver.debug("Serialize.store: " + sb.toString() );
ResultSet rs = ((org.postgresql.jdbc1.AbstractJdbc1Connection)conn).ExecSQL(sb.toString()); ResultSet rs = ((org.postgresql.jdbc1.AbstractJdbc1Connection)conn).ExecSQL(sb.toString());
// fetch the OID for returning // fetch the OID for returning
...@@ -496,13 +504,15 @@ public class Serialize ...@@ -496,13 +504,15 @@ public class Serialize
ResultSet rs = ((org.postgresql.jdbc1.AbstractJdbc1Connection)con).ExecSQL("select relname from pg_class where relname = '" + tableName + "'"); ResultSet rs = ((org.postgresql.jdbc1.AbstractJdbc1Connection)con).ExecSQL("select relname from pg_class where relname = '" + tableName + "'");
if ( rs.next() ) if ( rs.next() )
{ {
if (Driver.logDebug) Driver.debug("Serialize.create: table " + tableName + " exists, skipping"); if (Driver.logDebug)
Driver.debug("Serialize.create: table " + tableName + " exists, skipping");
rs.close(); rs.close();
return; return ;
} }
// else table not found, so create it // else table not found, so create it
if (Driver.logDebug) Driver.debug("Serialize.create: table " + tableName + " not found, creating" ); if (Driver.logDebug)
Driver.debug("Serialize.create: table " + tableName + " not found, creating" );
// No entries returned, so the table doesn't exist // No entries returned, so the table doesn't exist
StringBuffer sb = new StringBuffer("create table "); StringBuffer sb = new StringBuffer("create table ");
...@@ -548,7 +558,8 @@ public class Serialize ...@@ -548,7 +558,8 @@ public class Serialize
sb.append(")"); sb.append(")");
// Now create the table // Now create the table
if (Driver.logDebug) Driver.debug("Serialize.create: " + sb ); if (Driver.logDebug)
Driver.debug("Serialize.create: " + sb );
((org.postgresql.jdbc1.AbstractJdbc1Connection)con).ExecSQL(sb.toString()); ((org.postgresql.jdbc1.AbstractJdbc1Connection)con).ExecSQL(sb.toString());
} }
......
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