apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.89k stars 6.73k forks source link

ShardingSphereException:oracle.jdbc.driver.T4CConnection.getSchema() #14463

Closed JerryGHH closed 2 years ago

JerryGHH commented 2 years ago

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?

5.0.0

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

ShardingSphere-JDBC

Expected behavior

Actual behavior

Reason analyze (If you can)

datasource:

com.oracle ojdbc6 11.2.0.1.0

when the application start,will throw this exception:

org.apache.shardingsphere.infra.exception.ShardingSphereException: java.util.concurrent.ExecutionException: java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.getSchema()Ljava/lang/String; at org.apache.shardingsphere.infra.metadata.schema.builder.loader.TableMetaDataLoaderEngine.loadByDialect(TableMetaDataLoaderEngine.java:99) at org.apache.shardingsphere.infra.metadata.schema.builder.loader.TableMetaDataLoaderEngine.load(TableMetaDataLoaderEngine.java:66) at org.apache.shardingsphere.sharding.metadata.ShardingTableMetaDataBuilder.load(ShardingTableMetaDataBuilder.java:64) at org.apache.shardingsphere.sharding.metadata.ShardingTableMetaDataBuilder.load(ShardingTableMetaDataBuilder.java:51) at org.apache.shardingsphere.infra.metadata.schema.builder.TableMetaDataBuilder.load(TableMetaDataBuilder.java:65) at org.apache.shardingsphere.infra.metadata.schema.loader.SchemaLoader.load(SchemaLoader.java:71) at org.apache.shardingsphere.mode.manager.memory.MemoryContextManagerBuilder.build(MemoryContextManagerBuilder.java:54) at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:75) at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.(ShardingSphereDataSource.java:61) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:145) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122) at org.springframework.beans.factory.support.ConstructorResolver$1.run(ConstructorResolver.java:265) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:262) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1196) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5128) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5653) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1007) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:983) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:639) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1297) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2038) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWor

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

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

tuichenchuxin commented 2 years ago

Can it work normally? And can you offer a demo for me to try?

JerryGHH commented 2 years ago

Can it work normally? And can you offer a demo for me to try?

When the application starts, console will output exception information, but it will not block application start, work normally.

Related configuration:

<bean id="db1" class="com.alibaba.druid.pool.DruidDataSource"  destroy-method="close"> 
  <property name="url" value="jdbc:oracle:thin:@*.*.*.*:1521/**" />
  <property name="username" value="root" />
  <property name="password" value="root123" />
</bean>

<sharding:sharding-algorithm id="dljlTableAlgorithm" type="INTERVAL">
  <props>
    <prop key="datetime-pattern">yyyy-MM-dd HH:mm:ss</prop>
    <prop key="datetime-lower">2022-01-01 00:00:00</prop>
    <prop key="sharding-suffix-pattern">yyyyMM</prop>
    <prop key="datetime-interval-amount">1</prop>
    <prop key="datetime-interval-unit">MONTHS</prop>
  </props>
</sharding:sharding-algorithm>

<sharding:standard-strategy id="dljlTableStrategy" sharding-column="DLSJ" algorithm-ref="dljlTableAlgorithm" />

<sharding:rule id="shardingRules">
  <sharding:table-rules>
    <sharding:table-rule logic-table="YH_DLJL" actual-data-nodes="db1.YH_DLJL_20220$->{1..9},db1.yh_dljl_2022$->{10..12}" table-strategy-ref="dljlTableStrategy"/>
  </sharding:table-rules>
</sharding:rule>

<shardingsphere:data-source id="shardingDataSource"  data-source-names="db1" rule-refs="shardingRules"></shardingsphere:data-source>

POM xml:

<dependency>
  <groupId>org.apache.shardingsphere</groupId>
  <artifactId>shardingsphere-jdbc-core</artifactId>
  <version>5.0.0</version>
</dependency>

<dependency>
  <groupId>org.apache.shardingsphere</groupId>
  <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
  <version>5.0.0</version>
</dependency>

<dependency>
  <groupId>com.oracle</groupId>
  <artifactId>ojdbc6</artifactId>
  <version>11.2.0.1.0</version>
</dependency>
tuichenchuxin commented 2 years ago

which version is your oracle db?

JerryGHH commented 2 years ago

Oracle [Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production]

BEST REGARDS

 

------------------ Original ------------------ From: "apache/shardingsphere" @.>; Date: Mon, Jan 10, 2022 09:51 AM @.>; @.**@.>; Subject: Re: [apache/shardingsphere] ShardingSphereException:oracle.jdbc.driver.T4CConnection.getSchema() (Issue #14463)

which version is your oracle db?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

tuichenchuxin commented 2 years ago

@JerryGHH didn't have this version of Oracle. But I think it has some version problem. In this OracleTableMetaDataLoader class, you can debug to check. And submit a pr.

JerryGHH commented 2 years ago

Oracle Database 19c is the latest Long Term Release with the widest window of support duration.

Oracle DB Server version is 19c,and my oracle driver is 11.2.0.1.0。

the maven dependency is :

<dependency>        <groupId>com.oracle</groupId>        <artifactId>ojdbc6</artifactId>        <version>11.2.0.1.0</version> </dependency>

In this OracleTableMetaDataLoader class line 85,connection.getSchema() this code will throw exception。

 

------------------ Original ------------------ From: "apache/shardingsphere" @.>; Date: Mon, Jan 10, 2022 10:09 AM @.>; @.**@.>; Subject: Re: [apache/shardingsphere] ShardingSphereException:oracle.jdbc.driver.T4CConnection.getSchema() (Issue #14463)

@JerryGHH didn't have this version of Oracle. But I think it has some version problem. In this OracleTableMetaDataLoader class, you can debug to check. And submit a pr.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

maxiaof commented 2 years ago

I tried to upgrade the Oracle driver to solve this problem

<dependency>
  <groupId>com.oracle</groupId>
  <artifactId>ojdbc6</artifactId>
  <version>11.2.0.1.0</version>
</dependency>

Change to

<dependency>
    <groupId>com.oracle.database.jdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>12.2.0.1</version>
</dependency>