stevefan1999-personal opened a new issue #7465:
URL: https://github.com/apache/shardingsphere/issues/7465


   ### Which version of ShardingSphere did you use?
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   `version.org.apache.shardingsphere..sharding-jdbc-spring-boot-starter=4.1.1`
   
   ### Expected behavior
   It should run
   
   ### Actual behavior
   Hikari can connect to the DB and start data sourcing/pooling, but because 
this particular style of connection string (TNS alias) is not conventional, 
ShardingSphere validator regex for Oracle fails to accept it.
   
   Caused by: 
org.apache.shardingsphere.underlying.common.database.metadata.UnrecognizedDatabaseURLException:
 The URL: 'jdbc:oracle:thin:@db202008101919_high' is not recognized. Please 
refer to this pattern: 
'jdbc:oracle:(thin|oci|kprb):@(//)?([\w\-\.]+):?([0-9]*)[:/]([\w\-]+)'.
   
   
   I tried to add some minimal changes to match the regex, like appending '/' 
or ':' to the end and add '-' as Oracle doesn't really have the concept of 
multiple databases (like Postgres it is user per database). It looks like this:
   ```
   jdbc:oracle:thin:@db202008101919_high/-
   jdbc:oracle:thin:@db202008101919_high:-
   ```
   But then Hikari fails to connect
   
   ### Reason analyze (If you can)
   Obviously the regex only accounts for sqlplus style connection string
   
   
https://docs.oracle.com/en/cloud/paas/autonomous-data-warehouse-cloud/user/connect-jdbc-thin-wallet.html#GUID-1640CC02-BF3E-48C2-8FFE-A596614A6A40
   
   But autonomous database use TNS alias style instead
   
   ### Possible fix
   Change the regex from 
   `jdbc:oracle:(thin|oci|kprb):@(//)?([\w\-\.]+):?([0-9]*)[:/]([\w\-]+)`
   to
   `jdbc:oracle:(thin|oci|kprb):@(//)?([\w\-\.]+):?([0-9]*)[:/]?([\w\-]+)`
   
   But this could potentially break existing application (I guess)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   This is my partial application.yml
   ```yaml
   spring:
     shardingsphere:
       datasource:
         names: ds0,ds1
         ds0:
           driver-class-name: oracle.jdbc.OracleDriver
           jdbcUrl: jdbc:oracle:thin:@db202008101919_high
           password: attack at dawn
           type: com.zaxxer.hikari.HikariDataSource
           username: admin
         ds1:
           driver-class-name: oracle.jdbc.OracleDriver
           jdbcUrl: jdbc:oracle:thin:@db202008101919_low
           password: attack at dawn
           type: com.zaxxer.hikari.HikariDataSource
           username: admin
   ```
   
   ### Workaround
   - Downgrade to 3.x
   - Manually replace all connection details to be like other normal connection 
string
   - Wait for 5.x to release and use 
https://github.com/apache/shardingsphere/issues/7195


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to