CopyManager uses BaseConnection and I've lost mine
От | Rob Sargent |
---|---|
Тема | CopyManager uses BaseConnection and I've lost mine |
Дата | |
Msg-id | e9998831-264c-2f70-f1c6-62905a4d75fb@gmail.com обсуждение исходный текст |
Ответы |
Re: CopyManager uses BaseConnection and I've lost mine
|
Список | pgsql-jdbc |
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
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?
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.BaseConnectionon 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?
В списке pgsql-jdbc по дате отправления: