pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Error when attempting to call Connection.createArrayOf() method
6+ messages / 4 participants
[nested] [flat]

* Error when attempting to call Connection.createArrayOf() method
@ 2009-12-16 09:47 Allan Kamau <kamauallan@gmail.com>
  2009-12-16 09:54 ` Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
  2009-12-16 13:38 ` Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Allan Kamau @ 2009-12-16 09:47 UTC (permalink / raw)
  To: pgsql-jdbc

I am trying create an array of text to pass to a postgreSQL function
and I am getting the following error
"java.lang.AbstractMethodError:
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;"

I have tried googling for a possible solution without much success the
closed I got was the discussion in this thread
"http://archives.postgresql.org/pgsql-jdbc/2009-04/msg00013.php"; but I
am unable to find the successful conclusion/solution for this error.

I am using JDBC driver (postgresql-8.4-701.jdbc4.jar) for postgreSQL
and commons-dbcp-1.2.2.jar for connection pooling.

My code like like this.


       public static int persistUserInput(
               Connection conn,String
_user_input_id,Map<String,Vector<String>> userInputMap
       )throws SQLException
       {
               int _rows_affected=-1;
               String _input_name=null;
               String _input_values[]=new String[0];
               PreparedStatement ps=null;ResultSet rs=null;
               for (Map.Entry<String,Vector<String>> y :
userInputMap.entrySet())
               {
                       _input_name=y.getKey();
                       Vector<String> v=y.getValue();
                       _input_values=v.toArray(_input_values);
                       try
                       {

                               String _sql_query=""
                                       +" SELECT persist_user_input(?,?,?);"
                               ;
                               ps=conn.prepareStatement(_sql_query);
                               ps.setString(1,_user_input_id);
                               ps.setString(2,_input_name);

ps.setArray(3,conn.createArrayOf("text",_input_values));
                               rs=ps.executeQuery();
                               if(rs.next())
                               {
                                       _rows_affected=rs.getInt(1);
                               }
                               rs.close();
                               ps.close();
                       }
                       catch(SQLException e)
                       {
                               throw e;
                       }
                       finally
                       {
                               /*
                               rs.close();
                               ps.close();
                               if(rs!=null&&!rs.isClosed())
                               {
                                       rs.close();
                               }
                               rs=null;
                               if(ps!=null&&!ps.isClosed())
                               {
                                       ps.close();
                               }
                               ps=null;
                               */
                       }
               }
               return _rows_affected;
       }



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Error when attempting to call Connection.createArrayOf() method
  2009-12-16 09:47 Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
@ 2009-12-16 09:54 ` Allan Kamau <kamauallan@gmail.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Allan Kamau @ 2009-12-16 09:54 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,
I am trying create an array of text to pass to a postgreSQL function
and I am getting the following error
"java.lang.AbstractMethodError:
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;"

I have tried googling for a possible solution without much success the
closed I got was the discussion in this mailing list but I
am unable to find the successful conclusion/solution for this error.

I am using JDBC driver (postgresql-8.4-701.jdbc4.jar) for postgreSQL
and commons-dbcp-1.2.2.jar for connection pooling.

My code like like this.


      public static int persistUserInput(
              Connection conn,String
_user_input_id,Map<String,Vector<String>> userInputMap
      )throws SQLException
      {
              int _rows_affected=-1;
              String _input_name=null;
              String _input_values[]=new String[0];
              PreparedStatement ps=null;ResultSet rs=null;
              for (Map.Entry<String,Vector<String>> y :
userInputMap.entrySet())
              {
                      _input_name=y.getKey();
                      Vector<String> v=y.getValue();
                      _input_values=v.toArray(_input_values);
                      try
                      {

                              String _sql_query=""
                                      +" SELECT persist_user_input(?,?,?);"
                              ;
                              ps=conn.prepareStatement(_sql_query);
                              ps.setString(1,_user_input_id);
                              ps.setString(2,_input_name);

ps.setArray(3,conn.createArrayOf("text",_input_values));
                              rs=ps.executeQuery();
                              if(rs.next())
                              {
                                      _rows_affected=rs.getInt(1);
                              }
                              rs.close();
                              ps.close();
                      }
                      catch(SQLException e)
                      {
                              throw e;
                      }
                      finally
                      {
                              /*
                              rs.close();
                              ps.close();
                              if(rs!=null&&!rs.isClosed())
                              {
                                      rs.close();
                              }
                              rs=null;
                              if(ps!=null&&!ps.isClosed())
                              {
                                      ps.close();
                              }
                              ps=null;
                              */
                      }
              }
              return _rows_affected;
      }


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Error when attempting to call Connection.createArrayOf() method
  2009-12-16 09:47 Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
@ 2009-12-16 13:38 ` Allan Kamau <kamauallan@gmail.com>
  2009-12-16 14:00   ` Re: Error when attempting to call Connection.createArrayOf() method Guillaume Cottenceau <gc@mnc.ch>
  2009-12-18 15:10   ` Re: Error when attempting to call Connection.createArrayOf() method Dave Cramer <pg@fastcrypt.com>
  2009-12-18 22:27   ` Re: Error when attempting to call Connection.createArrayOf() method Kris Jurka <books@ejurka.com>
  1 sibling, 3 replies; 6+ messages in thread

From: Allan Kamau @ 2009-12-16 13:38 UTC (permalink / raw)
  To: pgsql-jdbc

I am trying create an array of text to pass to a postgreSQL function
and I am getting the following error
"java.lang.AbstractMethodError:
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;"


I am using JDBC driver (postgresql-8.4-701.jdbc4.jar) for postgreSQL
and commons-dbcp-1.2.2.jar for connection pooling.

My code like like this.

String[] _input_values={"one","two"};
conn.createArrayOf("text",_input_values)


Allan.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error when attempting to call Connection.createArrayOf() method
  2009-12-16 09:47 Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
  2009-12-16 13:38 ` Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
@ 2009-12-16 14:00   ` Guillaume Cottenceau <gc@mnc.ch>
  2 siblings, 0 replies; 6+ messages in thread

From: Guillaume Cottenceau @ 2009-12-16 14:00 UTC (permalink / raw)
  To: Allan Kamau <kamauallan@gmail.com>; +Cc: pgsql-jdbc

Allan Kamau <kamauallan 'at' gmail.com> writes:

> I am trying create an array of text to pass to a postgreSQL function

I personally use the following workaround to send arrays to PG,
it might be helpful for you too:

http://zarb.org/~gc/html/doc-misc.html#2008-08-21

BR

-- 
Guillaume Cottenceau



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error when attempting to call Connection.createArrayOf() method
  2009-12-16 09:47 Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
  2009-12-16 13:38 ` Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
@ 2009-12-18 15:10   ` Dave Cramer <pg@fastcrypt.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Dave Cramer @ 2009-12-18 15:10 UTC (permalink / raw)
  To: Allan Kamau <kamauallan@gmail.com>; +Cc: pgsql-jdbc

On Wed, Dec 16, 2009 at 8:38 AM, Allan Kamau <kamauallan@gmail.com> wrote:
> I am trying create an array of text to pass to a postgreSQL function
> and I am getting the following error
> "java.lang.AbstractMethodError:
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;"
>
>
> I am using JDBC driver (postgresql-8.4-701.jdbc4.jar) for postgreSQL
> and commons-dbcp-1.2.2.jar for connection pooling.
>
> My code like like this.
>
> String[] _input_values={"one","two"};
> conn.createArrayOf("text",_input_values)
>
>
AFAIR, Kris implemented this,does this work if you do not use dbpc ?

Dave



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error when attempting to call Connection.createArrayOf() method
  2009-12-16 09:47 Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
  2009-12-16 13:38 ` Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
@ 2009-12-18 22:27   ` Kris Jurka <books@ejurka.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Kris Jurka @ 2009-12-18 22:27 UTC (permalink / raw)
  To: Allan Kamau <kamauallan@gmail.com>; +Cc: pgsql-jdbc



On Wed, 16 Dec 2009, Allan Kamau wrote:

> I am trying create an array of text to pass to a postgreSQL function
> and I am getting the following error
> "java.lang.AbstractMethodError:
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;"

This error is the result of using a JDBC4 method (createArrayOf) on a 
non-JDBC4 Connection.  Apparently DBCP doesn't support JDBC4.  See, for 
example, this message:

http://www.mail-archive.com/user@commons.apache.org/msg03376.html

The reply's suggestion of unwrapping the DBCP connection to get the 
postgresql connection object is likely to work.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2009-12-18 22:27 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-12-16 09:47 Error when attempting to call Connection.createArrayOf() method Allan Kamau <kamauallan@gmail.com>
2009-12-16 09:54 ` Allan Kamau <kamauallan@gmail.com>
2009-12-16 13:38 ` Allan Kamau <kamauallan@gmail.com>
2009-12-16 14:00   ` Guillaume Cottenceau <gc@mnc.ch>
2009-12-18 15:10   ` Dave Cramer <pg@fastcrypt.com>
2009-12-18 22:27   ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox