gpt4 book ai didi

spring-boot - java.lang.IllegalStateException : Unable to detect database type for Sybase datasource 错误

转载 作者:行者123 更新时间:2023-12-05 07:43:12 29 4
gpt4 key购买 nike

我收到无法检测在我的 spring boot 应用程序中配置的 Sybase 数据源的数据库类型。

Spring Boot版本:1.5.3

application.properties

spring.datasource.url=jdbc:jtds:sybase://db-server-name:5555/DBNAME
spring.datasource.username=db_user
spring.datasource.password=db_password
spring.datasource.driver-class-name=net.sourceforge.jtds.jdbc.Driver

spring.jpa.database=sybase
spring.jpa.database-platform=org.hibernate.dialect.SybaseDialect

调试信息:

// line number 75 in AbstractDatabaseInitializer class
String productName = JdbcUtils.commonDatabaseName(JdbcUtils
.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName")
.toString());
// productName is returned as Sybase from JdbcUtils.extractDatabaseMetaData
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName);
// but there is no databaseDriver found and is returned as UNKNOWN.
// There is no Sybase database configured in DatabaseDriver enum

DatabaseDriver 枚举中没有配置 Sybase 数据源。你能快速帮助解决这个问题吗?

供引用的错误堆栈跟踪:

Caused by: java.lang.IllegalStateException: Unable to detect database type
at org.springframework.boot.autoconfigure.AbstractDatabaseInitializer.getDatabaseName(AbstractDatabaseInitializer.java:80)
at org.springframework.boot.autoconfigure.batch.BatchDatabaseInitializer.getDatabaseName(BatchDatabaseInitializer.java:54)
at org.springframework.boot.autoconfigure.AbstractDatabaseInitializer.initialize(AbstractDatabaseInitializer.java:61)
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:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)
... 17 common frames omitted

最佳答案

它对我有用。只需将此属性放在 application.properties 文件中。我遇到了 mysql 问题,所以如果您使用其他数据库,我在这里传递了 mysql(例如:schema-sybase.sql)

spring.batch.schema=classpath:org/springframework/batch/core/schema-mysql.sql

看起来我们的检测算法被 MySQL 破坏了,所以我创建了这个问题来仔细检查它。

同时,请指定您的初始化脚本的路径,这将防止 Spring Boot 尝试自动检测它。

关于spring-boot - java.lang.IllegalStateException : Unable to detect database type for Sybase datasource 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43886812/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com