gpt4 book ai didi

java - 运行 spring 应用程序时出错( org.h2.jdbc.JdbcSQLNonTransientConnectionException : URL format error)

转载 作者:行者123 更新时间:2023-12-01 17:55:25 27 4
gpt4 key购买 nike

我正在尝试使用 h2 嵌入式持久数据库。

运行应用程序时出现以下错误-

    2020-03-17 21:12:59.811  INFO 6204 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-03-17 21:13:00.868 ERROR 6204 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.

org.h2.jdbc.JdbcSQLNonTransientConnectionException: URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:file:C:/data/sample" [90046-200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:622) ~[h2-1.4.200.jar:1.4.200]
at ...

我的应用程序属性

spring.datasource.url=jdbc:h2:file:C:/data/sample;SET CACHE_SIZE 8192;DB_CLOSE_ON_EXIT=TRUE;AUTO_RECONNECT=TRUE

spring.datasource.driverClassName=org.h2.Driver

spring.datasource.username=sa

spring.datasource.password=

spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

spring.h2.console.enabled=true

最佳答案

您需要将 SET CACHE SIZE 8192; 替换为 CACHE_SIZE=8192;

jdbc:h2:file:C:/data/sample;CACHE_SIZE=8192;DB_CLOSE_ON_EXIT=TRUE;AUTO_RECONNECT=TRUE

关于java - 运行 spring 应用程序时出错( org.h2.jdbc.JdbcSQLNonTransientConnectionException : URL format error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60726203/

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