diff --git a/databend-jdbc/src/main/java/com/databend/jdbc/DatabendPreparedStatement.java b/databend-jdbc/src/main/java/com/databend/jdbc/DatabendPreparedStatement.java index a870af5..610e8d4 100644 --- a/databend-jdbc/src/main/java/com/databend/jdbc/DatabendPreparedStatement.java +++ b/databend-jdbc/src/main/java/com/databend/jdbc/DatabendPreparedStatement.java @@ -416,7 +416,7 @@ protected boolean execute(List statements) throws SQLExcep try { for (int i = 0; i < statements.size(); i++) { String sql = statements.get(i).getSql(); - if (sql.toLowerCase().contains("insert")) { + if (sql.toLowerCase().contains("insert") && !sql.toLowerCase().contains("select")) { handleBatchInsert(); } else { execute(sql); diff --git a/databend-jdbc/src/test/java/com/databend/jdbc/TestPrepareStatement.java b/databend-jdbc/src/test/java/com/databend/jdbc/TestPrepareStatement.java index a5fdd69..d5ba6c3 100644 --- a/databend-jdbc/src/test/java/com/databend/jdbc/TestPrepareStatement.java +++ b/databend-jdbc/src/test/java/com/databend/jdbc/TestPrepareStatement.java @@ -395,6 +395,12 @@ public void testUpdateSetNull() throws SQLException { Assertions.assertEquals(null, r.getString(2)); } } + String insertSelectSql = "insert overwrite test_prepare_statement select * from test_prepare_statement"; + try (PreparedStatement statement = conn.prepareStatement(insertSelectSql)) { + statement.execute(); + } catch (Exception e) { + e.printStackTrace(); + } } @Test