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 2019/08/30 09:14:23 UTC

[GitHub] [incubator-shardingsphere] M-make opened a new issue #2957: Code shardingTransactionManagerEngine.getTransactionManager(transactionType) always null

M-make opened a new issue #2957: Code shardingTransactionManagerEngine.getTransactionManager(transactionType) always null
URL: https://github.com/apache/incubator-shardingsphere/issues/2957
 
 
   ### tool
   Sharding-proxy
   
   ### error
   ```log
   java.lang.NullPointerException: null
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.createConnection(JDBCBackendDataSource.java:150)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.getConnections(JDBCBackendDataSource.java:123)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnectionFromUnderlying(BackendConnection.java:189)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnectionsWithoutTransaction(BackendConnection.java:172)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnections(BackendConnection.java:141)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.callback.ProxyJDBCExecutePrepareCallback.getConnections(ProxyJDBCExecutePrepareCallback.java:56)
   	at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getSQLExecuteGroups(SQLExecutePrepareTemplate.java:89)
   	at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getSynchronizedExecuteUnitGroups(SQLExecutePrepareTemplate.java:67)
   	at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getExecuteUnitGroups(SQLExecutePrepareTemplate.java:59)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.JDBCExecuteEngine.execute(JDBCExecuteEngine.java:78)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:95)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:81)
   	at org.apache.shardingsphere.shardingproxy.backend.text.query.QueryBackendHandler.execute(QueryBackendHandler.java:54)
   	at org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:72)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:86)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:66)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   ```
   
   ### config-sharding.yaml
   ```xml
   schemaName: sharding_db
   
   dataSources:
     ds0:
       url: jdbc:mysql://132.232.39.227:3306/test?serverTimezone=UTC&useSSL=false
       username: root
       password: 88888888
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     ds1:
       url: jdbc:mysql://132.232.39.227:3307/test?serverTimezone=UTC&useSSL=false
       username: root
       password: 88888888
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
   
   shardingRule:
     defaultDatabaseStrategy:
       hint:
         algorithmClassName: org.DbHintShardingAlgorithm
     defaultTableStrategy:
       hint:
         algorithmClassName: org.TableHintShardingAlgorithm
   ```
   
   ### DbHintShardingAlgorithm
   ```java
   public class DbHintShardingAlgorithm implements HintShardingAlgorithm<Integer> {
       @Override
       public Collection<String> doSharding(Collection<String> availableTargetNames, HintShardingValue<Integer> shardingValue) {
           Collection<String> tables = new ArrayList<>();
           for (String availableTargetName : availableTargetNames) {
               tables.add(availableTargetName.split(".")[0]);
           }
           return tables;
       }
   }
   ```
   
   ### TableHintShardingAlgorithm
   ```java
   public class TableHintShardingAlgorithm implements HintShardingAlgorithm<Integer> {
       @Override
       public Collection<String> doSharding(Collection<String> availableTargetNames, HintShardingValue<Integer> shardingValue) {
           Collection<String> tables = new ArrayList<>();
           for (String availableTargetName : availableTargetNames) {
               tables.add(availableTargetName.split(".")[1]);
           }
           return tables;
       }
   }
   ```
   
   ### client
   ```java
   public class Test {
       public static void main(String[] args) {
           MysqlDataSource mysqlDataSource = new MysqlDataSource();
           mysqlDataSource.setUser("sharding");
           mysqlDataSource.setPassword("sharding");
           mysqlDataSource.setUrl("jdbc:mysql://localhost:3307/sharding_db?serverTimezone=UTC&useSSL=false");
           JdbcTemplate jdbcTemplate = new JdbcTemplate(mysqlDataSource);
           jdbcTemplate.query("select * from ds0.test_table1",new ColumnMapRowMapper());
   
       }
   }
   ```
   

----------------------------------------------------------------
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


With regards,
Apache Git Services