|
24 | 24 | import java.util.List; |
25 | 25 | import java.util.UUID; |
26 | 26 | import java.util.concurrent.TimeUnit; |
27 | | -import java.util.regex.Pattern; |
28 | 27 |
|
29 | 28 | public class StatementImpl implements Statement, JdbcV2Wrapper { |
30 | 29 | private static final Logger LOG = LoggerFactory.getLogger(StatementImpl.class); |
@@ -103,7 +102,7 @@ private void closePreviousResultSet() { |
103 | 102 | } |
104 | 103 | } |
105 | 104 |
|
106 | | - private ResultSetImpl executeQueryImpl(String sql, QuerySettings settings) throws SQLException { |
| 105 | + protected ResultSetImpl executeQueryImpl(String sql, QuerySettings settings) throws SQLException { |
107 | 106 | checkClosed(); |
108 | 107 | // Closing before trying to do next request. Otherwise, deadlock because previous connection will not be |
109 | 108 | // release before this one completes. |
@@ -151,12 +150,12 @@ private ResultSetImpl executeQueryImpl(String sql, QuerySettings settings) throw |
151 | 150 | @Override |
152 | 151 | public int executeUpdate(String sql) throws SQLException { |
153 | 152 | checkClosed(); |
154 | | - return executeUpdateImpl(sql, parseStatementType(sql), new QuerySettings().setDatabase(schema)); |
| 153 | + return executeUpdateImpl(sql, StatementParser.parsedStatement(sql).getType(), new QuerySettings().setDatabase(schema)); |
155 | 154 | } |
156 | 155 |
|
157 | | - protected int executeUpdateImpl(String sql, StatementType type, QuerySettings settings) throws SQLException { |
| 156 | + protected int executeUpdateImpl(String sql, StatementParser.StatementType type, QuerySettings settings) throws SQLException { |
158 | 157 | checkClosed(); |
159 | | - StatementParser.StatementType type = StatementParser.parsedStatement(sql).getType(); |
| 158 | + |
160 | 159 | if (type == StatementParser.StatementType.SELECT || type == StatementParser.StatementType.SHOW |
161 | 160 | || type == StatementParser.StatementType.DESCRIBE || type == StatementParser.StatementType.EXPLAIN) { |
162 | 161 | throw new SQLException("executeUpdate() cannot be called with a SELECT/SHOW/DESCRIBE/EXPLAIN statement", ExceptionUtils.SQL_STATE_SQL_ERROR); |
@@ -282,19 +281,16 @@ public void setCursorName(String name) throws SQLException { |
282 | 281 | @Override |
283 | 282 | public boolean execute(String sql) throws SQLException { |
284 | 283 | checkClosed(); |
285 | | - return executeImpl(sql, parseStatementType(sql), new QuerySettings().setDatabase(schema)); |
| 284 | + return executeImpl(sql, StatementParser.parsedStatement(sql).getType(), new QuerySettings().setDatabase(schema)); |
286 | 285 | } |
287 | 286 |
|
288 | | - public boolean executeImpl(String sql, StatementType type, QuerySettings settings) throws SQLException { |
| 287 | + public boolean executeImpl(String sql, StatementParser.StatementType type, QuerySettings settings) throws SQLException { |
289 | 288 | checkClosed(); |
290 | | - StatementParser.ParsedStatement parsedStatement = StatementParser.parsedStatement(sql); |
291 | | - StatementParser.StatementType type = parsedStatement.getType(); |
292 | | - |
293 | 289 | if (type == StatementParser.StatementType.SELECT || |
294 | 290 | type == StatementParser.StatementType.SHOW || |
295 | 291 | type == StatementParser.StatementType.DESCRIBE || |
296 | 292 | type == StatementParser.StatementType.EXPLAIN) { |
297 | | - currentResultSet = executeQuery(sql, settings); // keep open to allow getResultSet() |
| 293 | + currentResultSet = executeQueryImpl(sql, settings); // keep open to allow getResultSet() |
298 | 294 | return true; |
299 | 295 | } else if(type == StatementParser.StatementType.SET) { |
300 | 296 | executeUpdateImpl(sql, type, settings); |
|
0 commit comments