Spring Data JDBC Firebird dialect not recognized

前端 未结 5 933
谎友^
谎友^ 2021-01-13 19:28

I\'m trying to connect to Firebird database using Spring Data JDBC and Spring Boot. I\'ve created a simple app using Spring Tools. Spring Data JDBC doesn\'t recognize the di

5条回答
  •  无人共我
    2021-01-13 20:18

    I found myself facing the same issue after upgrading to SB 2.3.0. Mark's excellent answer (which btw has found itself to Spring Data migration docs), helped me solve it, but I found that adding the extra configuration to META-INF less than ideal.

    My solution, extending from the original answer:

    1. Implement the Dialect
    2. Provide a custom JDBC Configuration and override jdbcDialect():
    @Configuration
    public class SpringDataJdbcConfiguration extends AbstractJdbcConfiguration {
    
        @Override
        public Dialect jdbcDialect(NamedParameterJdbcOperations operations) {
            return operations.getJdbcOperations().execute((ConnectionCallback)
                    connection -> isInformix(connection) ? InformixDialect.INSTANCE : super.jdbcDialect(operations));
        }
    
        private boolean isInformix(Connection connection) throws SQLException {
            return connection.getMetaData().getDatabaseProductName().toUpperCase().contains("INFORMIX");
        }
    }
    

提交回复
热议问题