gpt4 book ai didi

java.sql.SQLException : Bad connection URL while accessing the database

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

我正在我的 Spring 配置文件之一中配置数据库详细信息,如下所示:

<bean id="awd" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.ibm.as400.access.AS400JDBCDriver"/>
<property name="url" value="jdbc:db2://123.43.133.257/XYZ" />
<property name="username" value="xyz" />
<property name="password" value="xyz" />
</bean>

当我尝试从 Java 端连接上述数据库时,出现以下异常:

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Bad connection URL
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:280)
... 139 more
Caused by: java.sql.SQLException: Bad connection URL
at com.ibm.u2.jdbc.UniJDBCMsgFactory.createException(UniJDBCMsgFactory.java:109)
at com.ibm.u2.jdbc.UniJDBCDriver.connect(UniJDBCDriver.java:116)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:164)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:153)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
at org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource.getConnection(AbstractRoutingDataSource.java:162)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
... 140 more

谁能告诉我这里出了什么问题吗?

最佳答案

您使用的是 AS400JDBCDriver,因此您的 jdbc url 应该类似于:

jdbc:as400://123.43.133.257/XYZ

而不是

jdbc:db2://123.43.133.257/XYZ

关于java.sql.SQLException : Bad connection URL while accessing the database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27620274/

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