org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported

Spring JIRA | Tzachi Ezra Torf-Fulton | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I am trying to use Presto JDBC driver with Spring-XD JDBC source but I as soon as I deploy the stream I get SQLFeatureNotSupportedException. This is because org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin function tries to call setAutoCommit(false) which is not supported by PrestoConnection. Reading some other related issues I tried to set testOnBorrow=false and validationQuery='select 1', but it did not seem to work. Also, I created a small test in Java and managed to query the table (added the code at the end), so the driver seems to work fine. In the mean while, I would like to know if there is any workaround for this issue. I am using spring-xd-1.2.1.RELEASE with Java 1.8.0_51 on Ubuntu 12.04.5 precise. *JDBC driver jar* I added the driver jar to xd/lib from here: https://prestodb.io/docs/current/installation/jdbc.html *This is how I create the stream* stream create foo --definition "jdbc --fixedDelay=30 --split=1 --url=jdbc:presto://localhost:8080/hive --query='SELECT * FROM fooTable limit 10' --driverClassName=com.facebook.presto.jdbc.PrestoDriver --testOnBorrow=false --validationQuery='select 1'|log" --deploy *Stack trace* 2015-09-02T14:15:59-0700 1.2.1.RELEASE ERROR task-scheduler-1 handler.LoggingHandler - org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:245) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:463) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy119.call(Unknown Source) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:298) at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:292) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported at com.facebook.presto.jdbc.PrestoConnection.setAutoCommit(PrestoConnection.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126) at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108) at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81) at com.sun.proxy.$Proxy120.setAutoCommit(Unknown Source) at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:225) ... 21 more *Test Class* public class Test { public static final String DB_URL = "jdbc:presto://localhost:8080/hive"; public static final String Template = "SELECT * FROM fooTable limit 10"; public static void main(String[] args) throws SQLException, IOException { Connection conn = null; Statement stmt = null; conn = DriverManager.getConnection(DB_URL, "test", null); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(Template); } }

    Spring JIRA | 1 year ago | Tzachi Ezra Torf-Fulton
    org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported
  2. 0

    I am trying to use Presto JDBC driver with Spring-XD JDBC source but I as soon as I deploy the stream I get SQLFeatureNotSupportedException. This is because org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin function tries to call setAutoCommit(false) which is not supported by PrestoConnection. Reading some other related issues I tried to set testOnBorrow=false and validationQuery='select 1', but it did not seem to work. Also, I created a small test in Java and managed to query the table (added the code at the end), so the driver seems to work fine. In the mean while, I would like to know if there is any workaround for this issue. I am using spring-xd-1.2.1.RELEASE with Java 1.8.0_51 on Ubuntu 12.04.5 precise. *JDBC driver jar* I added the driver jar to xd/lib from here: https://prestodb.io/docs/current/installation/jdbc.html *This is how I create the stream* stream create foo --definition "jdbc --fixedDelay=30 --split=1 --url=jdbc:presto://localhost:8080/hive --query='SELECT * FROM fooTable limit 10' --driverClassName=com.facebook.presto.jdbc.PrestoDriver --testOnBorrow=false --validationQuery='select 1'|log" --deploy *Stack trace* 2015-09-02T14:15:59-0700 1.2.1.RELEASE ERROR task-scheduler-1 handler.LoggingHandler - org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:245) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:463) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy119.call(Unknown Source) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:298) at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:292) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported at com.facebook.presto.jdbc.PrestoConnection.setAutoCommit(PrestoConnection.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126) at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108) at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81) at com.sun.proxy.$Proxy120.setAutoCommit(Unknown Source) at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:225) ... 21 more *Test Class* public class Test { public static final String DB_URL = "jdbc:presto://localhost:8080/hive"; public static final String Template = "SELECT * FROM fooTable limit 10"; public static void main(String[] args) throws SQLException, IOException { Connection conn = null; Statement stmt = null; conn = DriverManager.getConnection(DB_URL, "test", null); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(Template); } }

    Spring JIRA | 1 year ago | Tzachi Ezra Torf-Fulton
    org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported

    Root Cause Analysis

    1. java.sql.SQLFeatureNotSupportedException

      Disabling auto-commit mode not supported

      at com.facebook.presto.jdbc.PrestoConnection.setAutoCommit()
    2. presto-jdbc
      PrestoConnection.setAutoCommit
      1. com.facebook.presto.jdbc.PrestoConnection.setAutoCommit(PrestoConnection.java:128)
      1 frame
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:497)
      4 frames
    4. org.apache.tomcat
      DisposableConnectionFacade.invoke
      1. org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
      2. org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108)
      3. org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81)
      3 frames
    5. com.sun.proxy
      $Proxy120.setAutoCommit
      1. com.sun.proxy.$Proxy120.setAutoCommit(Unknown Source)
      1 frame
    6. Spring Framework
      DataSourceTransactionManager.doBegin
      1. org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:225)
      1 frame
    7. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
      2. org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:463)
      3. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276)
      4. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      4 frames
    8. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      2 frames
    9. com.sun.proxy
      $Proxy119.call
      1. com.sun.proxy.$Proxy119.call(Unknown Source)
      1 frame
    10. Spring Integration Core
      ErrorHandlingTaskExecutor$1.run
      1. org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:298)
      2. org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
      2 frames
    11. Spring Core
      SyncTaskExecutor.execute
      1. org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
      1 frame
    12. Spring Integration Core
      AbstractPollingEndpoint$Poller.run
      1. org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
      2. org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:292)
      2 frames
    13. Spring Context
      ReschedulingRunnable.run
      1. org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
      2. org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
      2 frames
    14. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      2. java.util.concurrent.FutureTask.run(FutureTask.java:266)
      3. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      4. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      5. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      6. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      7. java.lang.Thread.run(Thread.java:745)
      7 frames