You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/12/07 13:02:25 UTC

[GitHub] [shardingsphere] iamif3000 opened a new issue #8524: Exception in thread "main" java.lang.UnsupportedOperationException: Cannot support database type 'MySQL'

iamif3000 opened a new issue #8524:
URL: https://github.com/apache/shardingsphere/issues/8524


   ### Which version of ShardingSphere did you use?
   v4.1.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   jdbc
   
   ### Expected behavior
   
   ### Actual behavior
   throws exception
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   If I package the program to jar and run the jar file, I'll get 
   ```
   Exception in thread "main" java.lang.UnsupportedOperationException: Cannot support database type 'MySQL'
           at org.apache.shardingsphere.sql.parser.core.parser.SQLParserFactory.newInstance(SQLParserFactory.java:55)
           at org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor.towPhaseParse(SQLParserExecutor.java:55)
           at org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor.execute(SQLParserExecutor.java:47)
           at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse0(SQLParserEngine.java:79)
           at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse(SQLParserEngine.java:61)
           at org.apache.shardingsphere.underlying.route.DataNodeRouter.createRouteContext(DataNodeRouter.java:97)
           at org.apache.shardingsphere.underlying.route.DataNodeRouter.executeRoute(DataNodeRouter.java:89)
           at org.apache.shardingsphere.underlying.route.DataNodeRouter.route(DataNodeRouter.java:76)
           at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.MasterSlaveStatement.execute(MasterSlaveStatement.java:161)
           at com.test.TestMain.main(TestMain.java:50)
   
   # code --- start
   File yamlFile = new File(args[0]);
   DataSource ds = YamlMasterSlaveDataSourceFactory.createDataSource(yamlFile);
   Connection conn = ds.getConnection("proxy", "p123456");
   Statement stmt = conn.createStatement()
   stmt.execute("truncate table jmeter_test");
   for ... {
     stmt.execute("insert into jmeter_test values (null, now(), now(), now(), now(), " +
               "now(), now(), now(), now(), now(), " +
               "now(), now(), now(), now(), now(), " +
               "now(), now(), now(), now(), now(), " +
               "now(), now(), now(), now(), now(), " +
               "now(), unix_timestamp(), unix_timestamp(), unix_timestamp(), unix_timestamp())");
   }
   ...
   # code --- end
   
   # config-master_slave.yaml --- start
   dataSources:
     # 配置第 1 个数据源
     ds_master: !!com.alibaba.druid.pool.DruidDataSource
       driverClassName: com.mysql.jdbc.Driver
       url: jdbc:mysql://192.168.252.246:3306/proxy?serverTimezone=UTC&useSSL=false
       username: proxy
       password: p123456
       initialSize: 10   #连接池初始化连接数
       minIdle: 10       #连接池最小连接数
       maxActive: 10   #连接池最大连接数
     # 配置第 2 个数据源
     ds_slave0: !!com.alibaba.druid.pool.DruidDataSource
     #!!org.apache.commons.dbcp2.BasicDataSource
     #!!com.zaxxer.hikari.HikariDataSource
     #!!com.alibaba.druid.pool.DruidDataSource
       driverClassName: com.mysql.jdbc.Driver
       url: jdbc:mysql://192.168.252.237:3306/proxy?serverTimezone=UTC&useSSL=false
       username: proxy
       password: p123456
       initialSize: 10   #连接池初始化连接数
       minIdle: 10       #连接池最小连接数
       maxActive: 10   #连接池最大连接数
   
   masterSlaveRule:
     name: ds_ms
     masterDataSourceName: ds_master
     slaveDataSourceNames: [ds_slave0]
   
   # config-master_slave.yaml --- end
   ```
   ### Example codes for reproduce this issue (such as a github link).
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] iamif3000 edited a comment on issue #8524: Exception in thread "main" java.lang.UnsupportedOperationException: Cannot support database type 'MySQL'

Posted by GitBox <gi...@apache.org>.
iamif3000 edited a comment on issue #8524:
URL: https://github.com/apache/shardingsphere/issues/8524#issuecomment-740430599


   @tristaZero 
   The package is in the dependencies. And I unziped the jar file, .../shardingsphere/sql/parser/mysql/* are include.
   This is my pom file
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
   
       <groupId>org.example</groupId>
       <artifactId>jdbctest</artifactId>
       <version>1.0-SNAPSHOT</version>
   
       <properties>
           <shardingsphere.version>4.1.1</shardingsphere.version>
       </properties>
   
       <dependencies>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-core</artifactId>
               <version>${shardingsphere.version}</version>
           </dependency>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-sql-parser-mysql</artifactId>
               <version>${shardingsphere.version}</version>
           </dependency>
           <dependency>
               <groupId>mysql</groupId>
               <artifactId>mysql-connector-java</artifactId>
               <version>5.1.35</version>
           </dependency>
           <dependency>
               <groupId>org.yaml</groupId>
               <artifactId>snakeyaml</artifactId>
               <version>1.26</version>
           </dependency>
           <!--dependency>
               <groupId>org.apache.commons</groupId>
               <artifactId>commons-dbcp2</artifactId>
               <version>2.2.0</version>
           </dependency-->
           <!--dependency>
               <groupId>com.zaxxer</groupId>
               <artifactId>HikariCP</artifactId>
               <version>3.4.5</version>
           </dependency-->
           <dependency>
               <groupId>com.alibaba</groupId>
               <artifactId>druid</artifactId>
               <version>1.1.12</version>
           </dependency>
       </dependencies>
   
       <build>
           <resources>
               <resource>
                   <directory>src/main/resources</directory>
                   <includes>
                       <include>**/*.properties</include>
                       <include>**/*.xml</include>
                   </includes>
                   <filtering>true</filtering>
               </resource>
           </resources>
           <plugins>
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-compiler-plugin</artifactId>
                   <version>3.8.1</version>
                   <configuration>
                       <source>1.8</source>
                       <target>1.8</target>
                   </configuration>
               </plugin>
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-shade-plugin</artifactId>
                   <version>3.2.4</version>
                   <executions>
                       <execution>
                           <phase>package</phase>
                           <goals>
                               <goal>shade</goal>
                           </goals>
                           <configuration>
                               <artifactSet>
                                   <excludes>
   
                                   </excludes>
                               </artifactSet>
                               <filters>
                                   <filter>
                                       <!-- Do not copy the signatures in the META-INF folder.
                                       Otherwise, this might cause SecurityExceptions when using the JAR. -->
                                       <artifact>*:*</artifact>
                                       <excludes>
                                           <exclude>META-INF/*.SF</exclude>
                                           <exclude>META-INF/*.DSA</exclude>
                                           <exclude>META-INF/*.RSA</exclude>
                                       </excludes>
                                   </filter>
                               </filters>
                               <transformers>
                                   <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                       <mainClass>com.test.TestMain</mainClass>
                                   </transformer>
                               </transformers>
                           </configuration>
                       </execution>
                   </executions>
               </plugin>
           </plugins>
       </build>
   </project>
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero closed issue #8524: Exception in thread "main" java.lang.UnsupportedOperationException: Cannot support database type 'MySQL'

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #8524:
URL: https://github.com/apache/shardingsphere/issues/8524


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] iamif3000 commented on issue #8524: Exception in thread "main" java.lang.UnsupportedOperationException: Cannot support database type 'MySQL'

Posted by GitBox <gi...@apache.org>.
iamif3000 commented on issue #8524:
URL: https://github.com/apache/shardingsphere/issues/8524#issuecomment-740430599


   @tristaZero 
   The package is in the dependencies. And I unziped the tar file, .../shardingsphere/sql/parser/mysql/* are include.
   This is my pom file
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
   
       <groupId>org.example</groupId>
       <artifactId>jdbctest</artifactId>
       <version>1.0-SNAPSHOT</version>
   
       <properties>
           <shardingsphere.version>4.1.1</shardingsphere.version>
       </properties>
   
       <dependencies>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-core</artifactId>
               <version>${shardingsphere.version}</version>
           </dependency>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-sql-parser-mysql</artifactId>
               <version>${shardingsphere.version}</version>
           </dependency>
           <dependency>
               <groupId>mysql</groupId>
               <artifactId>mysql-connector-java</artifactId>
               <version>5.1.35</version>
           </dependency>
           <dependency>
               <groupId>org.yaml</groupId>
               <artifactId>snakeyaml</artifactId>
               <version>1.26</version>
           </dependency>
           <!--dependency>
               <groupId>org.apache.commons</groupId>
               <artifactId>commons-dbcp2</artifactId>
               <version>2.2.0</version>
           </dependency-->
           <!--dependency>
               <groupId>com.zaxxer</groupId>
               <artifactId>HikariCP</artifactId>
               <version>3.4.5</version>
           </dependency-->
           <dependency>
               <groupId>com.alibaba</groupId>
               <artifactId>druid</artifactId>
               <version>1.1.12</version>
           </dependency>
       </dependencies>
   
       <build>
           <resources>
               <resource>
                   <directory>src/main/resources</directory>
                   <includes>
                       <include>**/*.properties</include>
                       <include>**/*.xml</include>
                   </includes>
                   <filtering>true</filtering>
               </resource>
           </resources>
           <plugins>
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-compiler-plugin</artifactId>
                   <version>3.8.1</version>
                   <configuration>
                       <source>1.8</source>
                       <target>1.8</target>
                   </configuration>
               </plugin>
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-shade-plugin</artifactId>
                   <version>3.2.4</version>
                   <executions>
                       <execution>
                           <phase>package</phase>
                           <goals>
                               <goal>shade</goal>
                           </goals>
                           <configuration>
                               <artifactSet>
                                   <excludes>
   
                                   </excludes>
                               </artifactSet>
                               <filters>
                                   <filter>
                                       <!-- Do not copy the signatures in the META-INF folder.
                                       Otherwise, this might cause SecurityExceptions when using the JAR. -->
                                       <artifact>*:*</artifact>
                                       <excludes>
                                           <exclude>META-INF/*.SF</exclude>
                                           <exclude>META-INF/*.DSA</exclude>
                                           <exclude>META-INF/*.RSA</exclude>
                                       </excludes>
                                   </filter>
                               </filters>
                               <transformers>
                                   <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                       <mainClass>com.test.TestMain</mainClass>
                                   </transformer>
                               </transformers>
                           </configuration>
                       </execution>
                   </executions>
               </plugin>
           </plugins>
       </build>
   </project>
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] iamif3000 commented on issue #8524: Exception in thread "main" java.lang.UnsupportedOperationException: Cannot support database type 'MySQL'

Posted by GitBox <gi...@apache.org>.
iamif3000 commented on issue #8524:
URL: https://github.com/apache/shardingsphere/issues/8524#issuecomment-740471264


   I found the reason.
   Since I use shade for packaging, some META.service/xxx files are duplicated and only one will be kept. So SPI will only load one implementation.
   Solution: use assembly to package a zip or tar.gz instead.
   
   Please close this issue. Thanks.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #8524: Exception in thread "main" java.lang.UnsupportedOperationException: Cannot support database type 'MySQL'

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #8524:
URL: https://github.com/apache/shardingsphere/issues/8524#issuecomment-740416583


   > If I package the program to jar and run the jar file, I'll get
   
   Hi, I suggest you use pom file to run tests or clone this project. Your log shows me `<artifactId>shardingsphere-sql-parser-mysql</artifactId>` is not included in your libs.


----------------------------------------------------------------
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:
users@infra.apache.org