【Kingbase8資料庫】springboot jpa整合Kingbase8各種報錯

木头左發表於2024-03-30

Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set

去了stackoverflow: java - Spring Boot JPA - Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set - Stack Overflow 不是PostgreSQL,那就換成mysql的嘛:

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Kingbase8Dialect

Could not load requested class : org.hibernate.dialect.Kingbase8Dialect

增加方言類: class Kingbase8Dialect extends PostgreSQL9Dialect

    @Override
    public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
            throws SQLException {

        if (dbMetaData == null) {
            builder.setQuotedCaseStrategy(IdentifierCaseStrategy.MIXED);
        }
        builder.applyIdentifierCasing( dbMetaData );

        builder.applyReservedWords( dbMetaData );
        builder.applyReservedWords( AnsiSqlKeywords.INSTANCE.sql2003() );
        builder.applyReservedWords(super.getKeywords());

        builder.setNameQualifierSupport( getNameQualifierSupport() );
        builder.setUnquotedCaseStrategy(IdentifierCaseStrategy.MIXED);
        return builder.build();

Caused by: java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc:kingbase8:

增加配置: spring.datasource.ddb.driver-class-name=com.kingbase8.Driver

couldn’t deduct database type from database product name ‘KingbaseES’

相關文章