Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kylxZ-0004Cs-Sy for pgsql-jdbc@arkaria.postgresql.org; Mon, 11 Jan 2021 01:25:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kylxX-0005P5-CE for pgsql-jdbc@arkaria.postgresql.org; Mon, 11 Jan 2021 01:25:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kylxX-0005O7-4Z for pgsql-jdbc@lists.postgresql.org; Mon, 11 Jan 2021 01:25:27 +0000 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kylxP-0002pu-Cj for pgsql-jdbc@lists.postgresql.org; Mon, 11 Jan 2021 01:25:25 +0000 Received: by mail-ot1-x332.google.com with SMTP id b24so15543868otj.0 for ; Sun, 10 Jan 2021 17:25:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=0Nq6qoawjwxWJgBfyr6WIfa9tZfysCTjmZXRP8vrpDI=; b=T7cogvhTy+a9pczy8BxkEokFcTOeGqZJAaUGxDV732BPKb0jYDqLIaCFm38x1SVEbO 8VgwDFB4cqvgNDJHIWLmsI48MAwPcIeBKzx5Q7MrvWXk8o+no1mUOQvQ2sKFPdLOkR/G m1Rc6Aj3SkXDLnNwtqaRD4plqd9lTJh4DTF1vZykR+T5P6fPwzXED6TXhFueOd3vhhmc XT1aw0Hm1JXqNDVfMmBetaKYcMS+JOMgf8NnkWpyC7IJ4FPNC/sq49CEcBGd5YH5crqP gTMkpyHHjYbZP5N2ap6V4t8Ww5V7pPNKJEzURoKfCApHSGazW/HlU0Qd2uIQpN09B72n 3Ozg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=0Nq6qoawjwxWJgBfyr6WIfa9tZfysCTjmZXRP8vrpDI=; b=Vt98PiBTtfZEOdg34TLvH6T/ZombbKVegXaxjGkk6i6lpT88NIKEDoOh1fIA8P5Mow orp3IoJWGx0QHNWJq1nzSacnfvcUZIxAV4BFVoJUCqjJ4XYZdR3NXxY+V0NUfj/CnQZP W+nkV9BAZrkUG0xzpdw+h0d3gZSExHdMUHAjdSyAngGZsnTKYtObVQLa4RA1oCz7NBkX Sm5fbLKTloh+SP3eTx0tALp49ncwAoNGrlFCTyfHP4js/KUTNHoANCIQPlFT8Oa3zAEv fyXug7eY63p4dRmAJuVa1PuwZmvCCMBeEps/s59cSvs5fX3Dvn5dgwChN8UPuEVLIrin l+GQ== X-Gm-Message-State: AOAM530z9LQZytWDxohWZC3yRL42goAxnONXeTotSkB58D8FxHWpqD3Y LeAcwV+GUFMo7kToiuIkx9GchlQ3K8wh3Q== X-Google-Smtp-Source: ABdhPJx3tIzKBOg8q9xG594YoNx7ZjcC/hKT3FoqH2R2z/ZQqvNxo4sYwopLp5qPW2C2XxChzlJQDw== X-Received: by 2002:a9d:6208:: with SMTP id g8mr9754276otj.165.1610328317527; Sun, 10 Jan 2021 17:25:17 -0800 (PST) Received: from ?IPv6:2601:681:5500:dde0:d1d2:45b8:df72:2021? ([2601:681:5500:dde0:d1d2:45b8:df72:2021]) by smtp.gmail.com with ESMTPSA id t24sm3692927oij.7.2021.01.10.17.25.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Jan 2021 17:25:17 -0800 (PST) To: "pgsql-jdbc@lists.postgresql.org" From: Rob Sargent Subject: CopyManager uses BaseConnection and I've lost mine Message-ID: Date: Sun, 10 Jan 2021 18:25:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------ECE60E7D829242552CE1CA60" Content-Language: en-CA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------ECE60E7D829242552CE1CA60 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Maybe I'm getting a little ahead of myself. java 15 (Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing) tomcat 9.0.41 (org.apache.tomcat.jdbc.pool.DataSource) postgresql:42.2.+ jooq 3.14 Lots of db successful db interactions in this configuration, but when I want to use the CopyManager to slam lots of records home with     private void writeSegmentWithCOPY(DSLContext topctx, UUID markers, MapcsvIds){         topctx.transaction(topconf -> {           DSLContext ctx = DSL.using(topconf);           CopyManager copyManager = new CopyManager((BaseConnection) getConnection());           String copyToStatement = String.format("COPY %s FROM STDIN CSV", getStagingTableName());           createStagingTable(ctx, getStagingTableName());           CopyIn copyIn = copyManager.copyIn(copyToStatement); where "getConnection()" is a simple getter on java.sql.Connection class member which in turn set from JNDIDataSource.getConnection() and I'm getting class com.sun.proxy.$Proxy4 cannot be cast to class org.postgresql.core.BaseConnection on the "new CopyManager" line.  I had been using DriverManager, but thought that was inappropriate with tomcat in play. Two questions, aside from the obvious Walter Tango Foxtrot 1. The javadoc for BaseConnect suggests "Application code should not use this interface" but CopyManager expects exactly that.  Is that not a contradiction? 2. Is DriverManager more appropriate? --------------ECE60E7D829242552CE1CA60 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Maybe I'm getting a little ahead of myself.

java 15 (Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
tomcat 9.0.41 (org.apache.tomcat.jdbc.pool.DataSource)
postgresql:42.2.+
jooq 3.14

Lots of db successful db interactions in this configuration, but when I want to use the CopyManager to slam lots of records home with

    private void writeSegmentWithCOPY(DSLContext topctx, UUID markers, Map<String,UUID>csvIds){
        topctx.transaction(topconf -> {
          DSLContext ctx = DSL.using(topconf);
          CopyManager copyManager = new CopyManager((BaseConnection) getConnection());
          String copyToStatement = String.format("COPY %s FROM STDIN CSV", getStagingTableName());
          createStagingTable(ctx, getStagingTableName());
          CopyIn copyIn = copyManager.copyIn(copyToStatement);

where "getConnection()" is a simple getter on java.sql.Connection class member which in turn set from JNDI
DataSource.getConnection() and I'm getting
class com.sun.proxy.$Proxy4 cannot be cast to class org.postgresql.core.BaseConnection
on the "new CopyManager" line.  I had been using DriverManager, but thought that was inappropriate with tomcat in play.

Two questions, aside from the obvious Walter Tango Foxtrot
1. The javadoc for BaseConnect suggests "Application code should not use this interface" but CopyManager expects exactly that.  Is that not a contradiction?
2. Is DriverManager more appropriate?


--------------ECE60E7D829242552CE1CA60--