PreparedStatement addBatch()

Поиск
Список
Период
Сортировка
Искать

PreparedStatement addBatch()

От:
AgentM <agentm@cmu.edu>
Дата:
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.
-- 
><><><><><><><><><><><><
AgentM
agentm@cmu.edu

Re: PreparedStatement addBatch()

От:
Barry Lind <barry@xythos.com>
Дата:
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.


FAQ