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);
} }
......
...@@ -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());
} }
......
...@@ -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));
} }
} }
......
...@@ -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;
......
...@@ -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();
} }
......
...@@ -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
......
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