Re: PreparedStatement addBatch()

From: Barry Lind <barry(at)xythos(dot)com>
To: AgentM <agentm(at)cmu(dot)edu>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PreparedStatement addBatch()
Date: 2002-04-16 17:56:14
Message-ID: 3CBC65BE.2030602@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

This error means you are trying to call a jdbc2 method, but using the
jdbc1 version of the driver that doesn't contain that method. If you
get the correct version of the jar file and are running the correct jdk
this should work.

thanks,
--Barry

AgentM wrote:
> I'm trying to use the addBatch method on PreparedStatement using pgsql
> 7.2 and the equivalent driver. I'd like to use the PreparedStatement
> addBatch method as described at
> http://java.sun.com/products/jdk/1.2/docs/guide/jdbc/spec2/jdbc2.0.frame6.html
>
> However, when I try to use it as such, I get
> Exception in thread "main" java.lang.AbstractMethodError:
> org.postgresql.jdbc1.PreparedStatement.addBatch()V
> at X(X.java:294)
> at Wrapper.main(Wrapper.java:24)
> where X.java 294 is the
> ps.addBatch();
> call where ps is a PreparedStatement that has has been properly
> initialized and variables entered. Following is some sample code
> demonstrating the problem:
>
> import java.sql.*;
>
> public class pstest
> {
> public static void main(String[] args) throws
> ClassNotFoundException, SQLException {
> Class.forName("org.postgresql.Driver");
> System.out.println("Driver loaded.");
> Connection db =
> DriverManager.getConnection("jdbc:postgresql:Dud","postgres","pass");
> PreparedStatement ps=db.prepareStatement("INSERT INTO test
> VALUES (?);");
> //ps.clearBatch();
> for(int i=0;i<37;i++)
> {
> ps.setInt(1,i);
> ps.addBatch();
> }
> ps.executeBatch();
> ps.close();
> db.close();
> }
> }
> The program dies on the ps.clearBatch() line if uncommented so I am
> assuming that this JDBC functionality has simply not been written. Am I
> doing something wrong or is this a bug? Thanks.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message AgentM 2002-04-16 18:50:22 Meaningful Exception handling
Previous Message AgentM 2002-04-16 17:32:33 PreparedStatement addBatch()