我正在尝试使用 Spring-JDBC 连接到 Presto,我正在使用 Hikari CP 作为数据源。 这是我的配置:
@Bean
public DataSource myDataSource() {
HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setDriverClassName("com.facebook.presto.jdbc.PrestoDriver");
hikariDataSource.setJdbcUrl("xxxxxxx");
hikariDataSource.setMaximumPoolSize(10);
hikariDataSource.setMinimumIdle(5);
hikariDataSource.setIdleTimeout(10000);
hikariDataSource.setConnectionTimeout(60000);
hikariDataSource.setUsername("xxxx");
hikariDataSource.setPassword("xxxx");
hikariDataSource.setAutoCommit(false);
return hikariDataSource;
}
在我的服务类中 Autowiring 数据源时,出现此错误:
java.sql.SQLFeatureNotSupportedException: Disabling auto-commit mode not supported
at com.facebook.presto.jdbc.PrestoConnection.setAutoCommit(PrestoConnection.java:126) ~[presto-jdbc-0.163.jar:0.163]
依赖:针对Springboot base 1.5.10.RELEASE
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.8</version>
</dependency>
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>0.163</version>
</dependency>
最佳答案
您正在禁用自动提交模式:
hikariDataSource.setAutoCommit(false);
而您的 Presto 驱动程序不支持此操作并将抛出异常。从您的 @Bean
中删除 setAutoCommit(false)
。这在 open issue #3592 中进行了讨论。 .
另一种选择是将驱动程序更新到较新的版本,因为在 master 上自动提交是 already handled in PrestoConnection .最新版本为 0.197。
关于java - Presto JDBC 连接池创建错误 "Disabling auto-commit mode not supported",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49499208/