? diffs
Index: org/postgresql/jdbc3/AbstractJdbc3Statement.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java,v
retrieving revision 1.24
diff -c -r1.24 AbstractJdbc3Statement.java
*** org/postgresql/jdbc3/AbstractJdbc3Statement.java	28 Jan 2009 09:50:21 -0000	1.24
--- org/postgresql/jdbc3/AbstractJdbc3Statement.java	26 May 2009 08:52:59 -0000
***************
*** 3,26 ****
  * Copyright (c) 2004-2008, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
! *   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java,v 1.24 2009/01/28 09:50:21 jurka Exp $
  *
  *-------------------------------------------------------------------------
  */
  package org.postgresql.jdbc3;
  
  import java.math.BigDecimal;
! import java.sql.*;
  import java.util.Calendar;
  import java.util.Vector;
  
- import org.postgresql.util.PSQLException;
- import org.postgresql.util.PSQLState;
- import org.postgresql.core.Utils;
- import org.postgresql.core.QueryExecutor;
- import org.postgresql.core.Field;
  import org.postgresql.core.BaseConnection;
  import org.postgresql.util.GT;
  
  /**
   * This class defines methods of the jdbc3 specification.  This class extends
--- 3,37 ----
  * Copyright (c) 2004-2008, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
! *   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java,v 1.23 2008/11/15 17:48:53 jurka Exp $
  *
  *-------------------------------------------------------------------------
  */
  package org.postgresql.jdbc3;
  
  import java.math.BigDecimal;
! import java.sql.Array;
! import java.sql.Blob;
! import java.sql.Clob;
! import java.sql.ParameterMetaData;
! import java.sql.Ref;
! import java.sql.ResultSet;
! import java.sql.SQLException;
! import java.sql.Statement;
! import java.sql.Types;
  import java.util.Calendar;
+ import java.util.HashMap;
+ import java.util.Map;
+ import java.util.StringTokenizer;
  import java.util.Vector;
  
  import org.postgresql.core.BaseConnection;
+ import org.postgresql.core.Field;
+ import org.postgresql.core.QueryExecutor;
+ import org.postgresql.core.Utils;
  import org.postgresql.util.GT;
+ import org.postgresql.util.PSQLException;
+ import org.postgresql.util.PSQLState;
  
  /**
   * This class defines methods of the jdbc3 specification.  This class extends
***************
*** 141,157 ****
          if (autoGeneratedKeys == Statement.NO_GENERATED_KEYS)
              return executeUpdate(sql);
  
!         sql = addReturning(connection, sql, new String[]{"*"}, false);
!         wantsGeneratedKeysOnce = true;
  
!         return executeUpdate(sql);
      }
  
!     static String addReturning(BaseConnection connection, String sql, String columns[], boolean escape) throws SQLException
      {
-         if (!connection.haveMinimumServerVersion("8.2"))
-             throw new PSQLException(GT.tr("Returning autogenerated keys is only supported for 8.2 and later servers."), PSQLState.NOT_IMPLEMENTED);
- 
          sql = sql.trim();
          if (sql.endsWith(";"))
              sql = sql.substring(0, sql.length()-1);
--- 152,165 ----
          if (autoGeneratedKeys == Statement.NO_GENERATED_KEYS)
              return executeUpdate(sql);
  
!         sql = addReturning(sql, new String[]{"*"}, false);
  
!         executeReturning(sql);
!         return getUpdateCount();
      }
  
!     private static String addReturning(String sql, String columns[], boolean escape) throws SQLException
      {
          sql = sql.trim();
          if (sql.endsWith(";"))
              sql = sql.substring(0, sql.length()-1);
***************
*** 223,232 ****
          if (columnNames == null || columnNames.length == 0)
              return executeUpdate(sql);
  
!         sql = addReturning(connection, sql, columnNames, true);
!         wantsGeneratedKeysOnce = true;
  
!         return executeUpdate(sql);
      }
  
      /**
--- 231,240 ----
          if (columnNames == null || columnNames.length == 0)
              return executeUpdate(sql);
  
!         sql = addReturning(sql, columnNames, true);
  
!         executeReturning(sql);
!         return getUpdateCount();
      }
  
      /**
***************
*** 270,279 ****
          if (autoGeneratedKeys == Statement.NO_GENERATED_KEYS)
              return execute(sql);
  
!         sql = addReturning(connection, sql, new String[]{"*"}, false);
!         wantsGeneratedKeysOnce = true;
  
!         return execute(sql);
      }
  
      /**
--- 278,286 ----
          if (autoGeneratedKeys == Statement.NO_GENERATED_KEYS)
              return execute(sql);
  
!         sql = addReturning(sql, new String[]{"*"}, false);
  
!         return executeReturning(sql);
      }
  
      /**
***************
*** 357,369 ****
       */
      public boolean execute(String sql, String columnNames[]) throws SQLException
      {
!         if (columnNames == null || columnNames.length == 0)
              return execute(sql);
  
!         sql = addReturning(connection, sql, columnNames, true);
!         wantsGeneratedKeysOnce = true;
  
!         return execute(sql);
      }
  
      /**
--- 364,375 ----
       */
      public boolean execute(String sql, String columnNames[]) throws SQLException
      {
!         if (columnNames.length == 0)
              return execute(sql);
  
!         sql = addReturning(sql, columnNames, true);
  
!         return executeReturning(sql);
      }
  
      /**
***************
*** 553,559 ****
       */
      public void setURL(String parameterName, java.net.URL val) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setURL(String,URL)");
      }
  
      /**
--- 559,569 ----
       */
      public void setURL(String parameterName, java.net.URL val) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setURL(index,val);
      }
  
      /**
***************
*** 568,574 ****
       */
      public void setNull(String parameterName, int sqlType) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setNull(String,int)");
      }
  
      /**
--- 578,588 ----
       */
      public void setNull(String parameterName, int sqlType) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setNull(index,sqlType);
      }
  
      /**
***************
*** 584,590 ****
       */
      public void setBoolean(String parameterName, boolean x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setBoolean(String,boolean)");
      }
  
      /**
--- 598,608 ----
       */
      public void setBoolean(String parameterName, boolean x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setBoolean(index,x);
      }
  
      /**
***************
*** 600,606 ****
       */
      public void setByte(String parameterName, byte x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setByte(String,byte)");
      }
  
      /**
--- 618,628 ----
       */
      public void setByte(String parameterName, byte x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setByte(index,x);
      }
  
      /**
***************
*** 616,622 ****
       */
      public void setShort(String parameterName, short x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setShort(String,short)");
      }
  
      /**
--- 638,648 ----
       */
      public void setShort(String parameterName, short x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setShort(index,x);
      }
  
      /**
***************
*** 632,638 ****
       */
      public void setInt(String parameterName, int x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setInt(String,int)");
      }
  
      /**
--- 658,668 ----
       */
      public void setInt(String parameterName, int x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setInt(index,x);
      }
  
      /**
***************
*** 648,654 ****
       */
      public void setLong(String parameterName, long x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setLong(String,long)");
      }
  
      /**
--- 678,688 ----
       */
      public void setLong(String parameterName, long x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setLong(index,x);
      }
  
      /**
***************
*** 664,670 ****
       */
      public void setFloat(String parameterName, float x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setFloat(String,float)");
      }
  
      /**
--- 698,708 ----
       */
      public void setFloat(String parameterName, float x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setFloat(index,x);
      }
  
      /**
***************
*** 680,686 ****
       */
      public void setDouble(String parameterName, double x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setDouble(String,double)");
      }
  
      /**
--- 718,728 ----
       */
      public void setDouble(String parameterName, double x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setDouble(index,x);
      }
  
      /**
***************
*** 697,703 ****
       */
      public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setBigDecimal(String,BigDecimal)");
      }
  
      /**
--- 739,749 ----
       */
      public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setBigDecimal(index,x);
      }
  
      /**
***************
*** 716,722 ****
       */
      public void setString(String parameterName, String x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setString(String,String)");
      }
  
      /**
--- 762,772 ----
       */
      public void setString(String parameterName, String x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found:"+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setString(index,x);        
      }
  
      /**
***************
*** 734,740 ****
       */
      public void setBytes(String parameterName, byte x[]) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setBytes(String,byte)");
      }
  
      /**
--- 784,794 ----
       */
      public void setBytes(String parameterName, byte x[]) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setBytes(index,x);
      }
  
      /**
***************
*** 751,757 ****
      public void setDate(String parameterName, java.sql.Date x)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setDate(String,Date)");
      }
  
      /**
--- 805,815 ----
      public void setDate(String parameterName, java.sql.Date x)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setDate(index,x);
      }
  
      /**
***************
*** 768,774 ****
      public void setTime(String parameterName, java.sql.Time x)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setTime(String,Time)");
      }
  
      /**
--- 826,836 ----
      public void setTime(String parameterName, java.sql.Time x)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setTime(index,x);
      }
  
      /**
***************
*** 786,792 ****
      public void setTimestamp(String parameterName, java.sql.Timestamp x)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setTimestamp(String,Timestamp)");
      }
  
      /**
--- 848,858 ----
      public void setTimestamp(String parameterName, java.sql.Timestamp x)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setTimestamp(index,x);
      }
  
      /**
***************
*** 811,817 ****
      public void setAsciiStream(String parameterName, java.io.InputStream x, int length)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setAsciiStream(String,InputStream,int)");
      }
  
      /**
--- 877,887 ----
      public void setAsciiStream(String parameterName, java.io.InputStream x, int length)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setAsciiStream(index,x,length);
      }
  
      /**
***************
*** 835,841 ****
      public void setBinaryStream(String parameterName, java.io.InputStream x,
                                  int length) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setBinaryStream(String,InputStream,int)");
      }
  
      /**
--- 905,915 ----
      public void setBinaryStream(String parameterName, java.io.InputStream x,
                                  int length) throws SQLException
      {
!     	int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setBinaryStream(index,x,length);
      }
  
      /**
***************
*** 873,879 ****
      public void setObject(String parameterName, Object x, int targetSqlType, int scale)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setObject(String,Object,int,int)");
      }
  
      /**
--- 947,957 ----
      public void setObject(String parameterName, Object x, int targetSqlType, int scale)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setObject(index,x,targetSqlType,scale);
      }
  
      /**
***************
*** 892,898 ****
      public void setObject(String parameterName, Object x, int targetSqlType)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setObject(String,Object,int)");
      }
  
      /**
--- 970,980 ----
      public void setObject(String parameterName, Object x, int targetSqlType)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setObject(index,x,targetSqlType);
      }
  
      /**
***************
*** 929,935 ****
       */
      public void setObject(String parameterName, Object x) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setObject(String,Object)");
      }
  
  
--- 1011,1021 ----
       */
      public void setObject(String parameterName, Object x) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setObject(index,x);
      }
  
  
***************
*** 957,963 ****
                                     java.io.Reader reader,
                                     int length) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setCharacterStream(String,Reader,int)");
      }
  
      /**
--- 1043,1053 ----
                                     java.io.Reader reader,
                                     int length) throws SQLException
      {
!     	int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setCharacterStream(index,reader,length);
      }
  
      /**
***************
*** 981,987 ****
      public void setDate(String parameterName, java.sql.Date x, Calendar cal)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setDate(String,Date,Calendar)");
      }
  
      /**
--- 1071,1081 ----
      public void setDate(String parameterName, java.sql.Date x, Calendar cal)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setDate(index,x,cal);
      }
  
      /**
***************
*** 1005,1011 ****
      public void setTime(String parameterName, java.sql.Time x, Calendar cal)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setTime(String,Time,Calendar)");
      }
  
      /**
--- 1099,1109 ----
      public void setTime(String parameterName, java.sql.Time x, Calendar cal)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setTime(index,x,cal);
      }
  
      /**
***************
*** 1029,1035 ****
      public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setTimestamp(String,Timestamp,Calendar)");
      }
  
      /**
--- 1127,1137 ----
      public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setTimestamp(index,x,cal);
      }
  
      /**
***************
*** 1064,1070 ****
      public void setNull (String parameterName, int sqlType, String typeName)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "setNull(String,int,String)");
      }
  
      /**
--- 1166,1176 ----
      public void setNull (String parameterName, int sqlType, String typeName)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	setNull(index,sqlType,typeName);
      }
  
      /**
***************
*** 1086,1092 ****
       */
      public String getString(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getString(String)");
      }
  
      /**
--- 1192,1202 ----
       */
      public String getString(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getString(index);
      }
  
      /**
***************
*** 1101,1107 ****
       */
      public boolean getBoolean(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getBoolean(String)");
      }
  
      /**
--- 1211,1221 ----
       */
      public boolean getBoolean(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getBoolean(index);
      }
  
      /**
***************
*** 1116,1122 ****
       */
      public byte getByte(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getByte(String)");
      }
  
      /**
--- 1230,1240 ----
       */
      public byte getByte(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getByte(index);
      }
  
      /**
***************
*** 1131,1137 ****
       */
      public short getShort(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getShort(String)");
      }
  
      /**
--- 1249,1259 ----
       */
      public short getShort(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getShort(index);
      }
  
      /**
***************
*** 1147,1153 ****
       */
      public int getInt(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getInt(String)");
      }
  
      /**
--- 1269,1279 ----
       */
      public int getInt(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getInt(index);
      }
  
      /**
***************
*** 1163,1169 ****
       */
      public long getLong(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getLong(String)");
      }
  
      /**
--- 1289,1299 ----
       */
      public long getLong(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getLong(index);
      }
  
      /**
***************
*** 1178,1184 ****
       */
      public float getFloat(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getFloat(String)");
      }
  
      /**
--- 1308,1318 ----
       */
      public float getFloat(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getFloat(index);
      }
  
      /**
***************
*** 1193,1199 ****
       */
      public double getDouble(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getDouble(String)");
      }
  
      /**
--- 1327,1337 ----
       */
      public double getDouble(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getDouble(index);
      }
  
      /**
***************
*** 1209,1215 ****
       */
      public byte[] getBytes(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getBytes(String)");
      }
  
      /**
--- 1347,1357 ----
       */
      public byte[] getBytes(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getBytes(index);
      }
  
      /**
***************
*** 1224,1230 ****
       */
      public java.sql.Date getDate(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getDate(String)");
      }
  
      /**
--- 1366,1376 ----
       */
      public java.sql.Date getDate(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getDate(index);
      }
  
      /**
***************
*** 1239,1245 ****
       */
      public java.sql.Time getTime(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getTime(String)");
      }
  
      /**
--- 1385,1395 ----
       */
      public java.sql.Time getTime(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getTime(index);
      }
  
      /**
***************
*** 1254,1260 ****
       */
      public java.sql.Timestamp getTimestamp(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getTimestamp(String)");
      }
  
      /**
--- 1404,1414 ----
       */
      public java.sql.Timestamp getTimestamp(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getTimestamp(index);
      }
  
      /**
***************
*** 1276,1282 ****
       */
      public Object getObject(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getObject(String)");
      }
  
      /**
--- 1430,1440 ----
       */
      public Object getObject(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getObject(index);
      }
  
      /**
***************
*** 1292,1298 ****
       */
      public BigDecimal getBigDecimal(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getBigDecimal(String)");
      }
  
      /**
--- 1450,1460 ----
       */
      public BigDecimal getBigDecimal(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getBigDecimal(index);
      }
  
      /**
***************
*** 1314,1320 ****
       */
      public Object getObjectImpl (String parameterName, java.util.Map map) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getObject(String,Map)");
      }
  
      /**
--- 1476,1486 ----
       */
      public Object getObjectImpl (String parameterName, java.util.Map map) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getObjectImpl(index,map);
      }
  
      /**
***************
*** 1330,1336 ****
       */
      public Ref getRef (String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getRef(String)");
      }
  
      /**
--- 1496,1506 ----
       */
      public Ref getRef (String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getRef(index);
      }
  
      /**
***************
*** 1346,1352 ****
       */
      public Blob getBlob (String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getBlob(String)");
      }
  
      /**
--- 1516,1526 ----
       */
      public Blob getBlob (String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getBlob(index);
      }
  
      /**
***************
*** 1361,1367 ****
       */
      public Clob getClob (String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getClob(String)");
      }
  
      /**
--- 1535,1545 ----
       */
      public Clob getClob (String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getClob(index);
      }
  
      /**
***************
*** 1377,1383 ****
       */
      public Array getArray (String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getArray(String)");
      }
  
      /**
--- 1555,1565 ----
       */
      public Array getArray (String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getArray(index);
      }
  
      /**
***************
*** 1402,1408 ****
      public java.sql.Date getDate(String parameterName, Calendar cal)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getDate(String,Calendar)");
      }
  
      /**
--- 1584,1594 ----
      public java.sql.Date getDate(String parameterName, Calendar cal)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getDate(index,cal);
      }
  
      /**
***************
*** 1427,1433 ****
      public java.sql.Time getTime(String parameterName, Calendar cal)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getTime(String,Calendar)");
      }
  
      /**
--- 1613,1623 ----
      public java.sql.Time getTime(String parameterName, Calendar cal)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getTime(index,cal);
      }
  
      /**
***************
*** 1453,1459 ****
      public java.sql.Timestamp getTimestamp(String parameterName, Calendar cal)
      throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getTimestamp(String,Calendar)");
      }
  
      /**
--- 1643,1653 ----
      public java.sql.Timestamp getTimestamp(String parameterName, Calendar cal)
      throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getTimestamp(index,cal);
      }
  
      /**
***************
*** 1471,1477 ****
       */
      public java.net.URL getURL(String parameterName) throws SQLException
      {
!         throw org.postgresql.Driver.notImplemented(this.getClass(), "getURL(String)");
      }
  
      public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
--- 1665,1675 ----
       */
      public java.net.URL getURL(String parameterName) throws SQLException
      {
!         int index = findParameterIndex(parameterName);
!         if (index == -1)
!         	throw new org.postgresql.util.PSQLException(GT.tr("Parameter not found: "+parameterName, this.getClass().getName()),PSQLState.NO_DATA);
!         else
!         	return getURL(index);
      }
  
      public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
***************
*** 1518,1521 ****
--- 1716,1803 ----
          // ignore scale for now
          registerOutParameter(parameterIndex, sqlType );
      }
+     
+     
+     // This map is for the next function
+     protected Map<String,Integer> parameterNameMap = new HashMap<String,Integer>();
+     private String actualProcedureName = "";
+         
+     protected int findNumberOfChars(String tmpString,char tmpChar)
+     {
+     	int number = 0;
+         if (tmpString!=null)
+         {
+         	while (tmpString.indexOf(tmpChar)!=-1)
+         	{
+         		tmpString = tmpString.substring(tmpString.indexOf(tmpChar)+1);
+         		number++;
+         	}
+         }
+         return number;
+     }
+     
+     /** 
+     * This is implementation of setParameter(String,Object) by the Name of the sored procedure parameter.
+     * 
+     * */
+     protected int findParameterIndex(String parameterName)
+     {
+        	// finding procedure name
+        	String procedureName = preparedQuery.toString();
+        	String selectQuery = null;
+        	procedureName = procedureName.substring(procedureName.indexOf("from")+5);
+        	
+        	int index = procedureName.indexOf('(');
+        	if (procedureName.indexOf(' ') < index)
+        		index = procedureName.indexOf(' '); 
+        	procedureName = procedureName.substring(0,index);
+     
+        	if (!actualProcedureName.equalsIgnoreCase(procedureName))
+        	{
+        		actualProcedureName = procedureName;
+        		parameterNameMap.clear();
+         	
+        		selectQuery = "select proargnames from pg_proc where proname ilike '"+procedureName+"'"; 
+        		selectQuery = selectQuery.replaceAll("\"","");
+         		
+     /*    		System.out.println("SQL = "+preparedQuery.toString());
+         		System.out.println("FULL SQL = "+preparedQuery.toString(preparedParameters)); */
+         	
+        		String parameters = null;
+        		ResultSet rs;
+        		try {
+        			rs = connection.createStatement().executeQuery(selectQuery);
+        			if (rs.next()) {
+        				parameters = rs.getString(1);
+        			}
+        			rs.close();
+        		} catch (SQLException e) {
+        			e.printStackTrace();
+        		}
+         		
+        		if (parameters != null)
+        		{
+        			parameters = parameters.substring(1,parameters.length()-1);
+         	    	
+        	    	StringTokenizer st = new StringTokenizer(parameters,",");
+        	    	int count = 1;
+         	    	
+        	    	if (findNumberOfChars(preparedQuery.toString(),'?') > findNumberOfChars(parameters,',')+1)
+        	    		count++;
+         	    	
+        	        while (st.hasMoreTokens()) {
+        	        	parameterNameMap.put(st.nextToken().toLowerCase(),count);
+        	        	count++;
+        	        }
+        		}
+        	}
+        	parameterName = parameterName.toLowerCase();
+         	
+        	Integer num = parameterNameMap.get(parameterName);
+        	if (num==null)
+        		return -1;
+        	else
+        		return num;
+     }
+     
  }
