Skip site navigation (1) Skip section navigation (2)

COPY problem in JDBC driver

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: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

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 {
			Connection connection = DriverManager.getConnection("jdbc:postgresql://","postgres", "postgres");
			PreparedStatement statement = connection.prepareStatement("DELETE FROM jdbctest");
			System.out.println("Erased Db");
			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){

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(
	at org.postgresql.core.v3.QueryExecutorImpl.startCopy(
	at org.postgresql.copy.CopyManager.copyIn(
	at tests.JDBCTest.main(

Has anyone noticed this before? Am I doing something wrong?




pgsql-jdbc by date

Next:From: Maciek SakrejdaDate: 2010-02-24 07:12:14
Subject: synchronization problems with COPY on connection failure
Previous:From: Oleg VasylenkoDate: 2010-02-23 10:57:14
Subject: SSL and PGPoolingDataSource

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group