Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H2 database url check exp error #33480

Open
lwr-max opened this issue Oct 31, 2024 · 1 comment
Open

H2 database url check exp error #33480

lwr-max opened this issue Oct 31, 2024 · 1 comment

Comments

@lwr-max
Copy link

lwr-max commented Oct 31, 2024

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

tag-5.3.2

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

Can run in win10 ,when h2 mode is file

Actual behavior

When h2 use file mode,can not connect database,because url check is error

Reason analyze (If you can)

shardingsphere\infra\common\src\main\java\org\apache\shardingsphere\infra\database\metadata\dialect\H2DataSourceMetaData.java
private static final Pattern PATTERN = Pattern.compile("jdbc:h2:((?mem|):/|"
+ "(?ssl:|tcp:)(//)?(?[\w\-.]+)(:(?[0-9]{1,4})/)?[/
\w\-.]+/(?[\-\w])|"
+ "(?file:)[/~\w\-]+/(?[\-\w]
));?\S*", Pattern.CASE_INSENSITIVE);
not concerned about url like jdbc:h2:file:D:/h2/data;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE in windows

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Only use in file mode,and url like jdbc:h2:file:D:/h2/data;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE,it will be reproduced

Example codes for reproduce this issue (such as a github link).

You can use this config
dataSources:
ds0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.h2.Driver
jdbcUrl: jdbc:h2:file:D:/05/h2/data;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL
username: admin
password: admin
rules:

  • !SHARDING
    tables:
    balance_account:
    actualDataNodes: ds${0}.balance_account_${2016..2030}
    tableStrategy:
    standard:
    shardingColumn: year
    shardingAlgorithmName: balance_account_inline
    shardingAlgorithms:
    balance_account_inline:
    type: INLINE
    props:
    algorithm-expression: balance_account_${year}
    props:
    sql-show: false
@terrymanu
Copy link
Member

Is the same issue present in the latest version as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants