PSQLException: ERROR: unknown variable: "transaction_read_only"

I am trying to replace postgre with cockroach in an application.

But on pointing to cockroach DB I am getting an exception like below -

connect URI is: jdbc:postgresql://localhost:26257/vnera?targetServerType=master
clear serviceType=SYSTEM serviceId= errorCode=EXPAND_PARTITION_FAILED customerId=null nodeId=IZVXO6F
Exception in thread "main" java.util.concurrent.ExecutionException: org.postgresql.util.PSQLException: ERROR: unknown variable: "transaction_read_only"

Any thoughts?

Looks like, one way or another, your application is sending a SET transaction_read_only = xxx statement. crdb doesn’t support that statement. It’s probably not very important for your application; can you get rid of it?

I was setting defaultReadOnly to false like-

PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
                    connectionFactory, connectionPool, null, null, false, true);

Changing this to null like below solved the issue.

PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, null, true, -1, null, null);

1 Like