繁体   English   中英

驱动程序 oracle.jdbc.OracleDriver 声称不接受 jdbcUrl

[英]Driver oracle.jdbc.OracleDriver claims to not accept jdbcUrl

我正在尝试连接到 Oracle DB。

当我尝试通过简单的 jdbc 连接进行连接时,它可以工作。

Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:thin:@chbsux0097.eu.novartis.net:1530:AD14", "xxxx", "xxxxx")

但是,它不适用于具有以下错误的Spring-boot

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-09 12:48:51.189 ERROR 16236 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.RuntimeException: Driver oracle.jdbc.OracleDriver claims to not accept jdbcUrl, jdbc:oracle:thin@chbsux0097.eu.novartis.net:1530:AD14
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]

应用程序属性

spring.datasource.username=xx
spring.datasource.password=xxxxx
spring.datasource.url=jdbc:oracle:thin@chbsux0097.eu.novartis.net:1530:AD14
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

在您的配置中thin后,您在 URL 中缺少一个冒号。 它必须是:

spring.datasource.url=jdbc:oracle:thin:@chbsux0097.eu.novartis.net:1530:AD14

请注意,冒号出现在您的工作简化示例中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM