From: | Michael Epstein <michael(dot)epstein(at)mac(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | COPY problem in JDBC driver |
Date: | 2010-02-23 19:44:22 |
Message-ID: | 34D76737-E848-4EB5-BE86-2988E39B5C9A@mac.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
I apologise in advance if this has been solved but I haven't found any reference to it online.
I am using the COPY implementation in the latest (postgresql-8.4-701.jdbc4) driver with Java VM 1.6.0 (Mac OSX)
My code is the following (just trying to insert a string from a file into a single column):
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
Connection connection = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/xseq_zip","postgres", "postgres");
PreparedStatement statement = connection.prepareStatement("DELETE FROM jdbctest");
statement.execute();
System.out.println("Erased Db");
System.out.println(connection.toString());
PGConnection pConn = (PGConnection)connection;
CopyManager copyManager = pConn.getCopyAPI();
String columns = "(name)";
copyManager.copyIn("COPY jdbctest " + columns + " FROM '" + "/Users/foobar/Documents/bulk.txt" + '");
}
catch (Exception ex){
ex.printStackTrace();
}
}
The code inserts the value from the file into the db but throws the following exception:
org.postgresql.util.PSQLException: Received CommandComplete 'COPY 1' without an active copy operation
at org.postgresql.core.v3.QueryExecutorImpl.processCopyResults(QueryExecutorImpl.java:918)
at org.postgresql.core.v3.QueryExecutorImpl.startCopy(QueryExecutorImpl.java:713)
at org.postgresql.copy.CopyManager.copyIn(CopyManager.java:52)
at tests.JDBCTest.main(JDBCTest.java:33)
Has anyone noticed this before? Am I doing something wrong?
Thanks
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Maciek Sakrejda | 2010-02-24 07:12:14 | synchronization problems with COPY on connection failure |
Previous Message | Oleg Vasylenko | 2010-02-23 10:57:14 | SSL and PGPoolingDataSource |