apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.95k stars 6.74k forks source link

JdbcTemplate DDL isn't working #3016

Closed happy89lgk closed 5 years ago

happy89lgk commented 5 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 more than 7 days 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?

4.0.0-RC2 but 4.0.0-RC1 is well

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

Sharding-JDBC

Expected behavior

JdbcTemplate DDL execute successfully

Actual behavior

JdbcTemplate DDL execute failed

Reason analyze (If you can)

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

2019-09-11 09:31:05 [http-nio-8080-exec-1] INFO ShardingSphere-SQL - Logic SQL: show tables like '2019_sys_login_log' 2019-09-11 09:31:05 [http-nio-8080-exec-1] INFO ShardingSphere-SQL - SQLStatement: TransparentOptimizedStatement(tables=Tables(tables=[Table(name=2019_sys_login_log, alias=Optional.absent())], schema=Optional.absent())) 2019-09-11 09:31:05 [http-nio-8080-exec-1] ERROR net.hj.base.controller.GlobalExceptionHandler - 出错 java.lang.IllegalArgumentException: null at com.google.common.base.Preconditions.checkArgument(Preconditions.java:111) at org.apache.shardingsphere.shardingjdbc.jdbc.adapter.AbstractResultSetAdapter.(AbstractResultSetAdapter.java:66) at org.apache.shardingsphere.shardingjdbc.jdbc.core.resultset.ShardingResultSet.(ShardingResultSet.java:51) at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingStatement.getCurrentResultSet(ShardingStatement.java:132) at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingStatement.getResultSet(ShardingStatement.java:128) at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingStatement.executeQuery(ShardingStatement.java:95) at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:439) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:376) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:452) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:462) at org.springframework.jdbc.core.JdbcTemplate.queryForList(JdbcTemplate.java:485) at net.hj.base.service.sys.impl.LoginLogServiceImpl.checkTable(LoginLogServiceImpl.java:80)

@Autowired private JdbcTemplate jdbcTemplate;

private void checkTable(String year) { String sql = "show tables like '"+year+"_sys_login_log'"; List tables = jdbcTemplate.queryForList(sql, String.class); if (tables.size() <= 0) { createTable(year); } }

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

sunbufu commented 5 years ago

If you have questions about show tables, please look at this first.

happy89lgk commented 5 years ago

ok,thank you