Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -753,4 +753,29 @@ public void testTimeZone(boolean useBinary) throws SQLException {
}
}
}

@Test(groups = "integration")
public void testInsertMultiple() throws SQLException {
try (ClickHouseConnection conn = newConnection(new Properties());
ClickHouseStatement s = conn.createStatement()) {
conn.createStatement().execute(
"DROP TABLE IF EXISTS test_insert_multiple");
conn.createStatement().execute(
"CREATE TABLE IF NOT EXISTS test_insert_multiple"
+ "(id UInt32, name String) "
+ "ENGINE = Memory");
try (PreparedStatement ps = conn.prepareStatement(
"INSERT INTO test_insert VALUES (?, ?), (?, ?)")) {
ps.setInt(1, 1);
ps.setString(2, "John");
ps.setInt(3, 2);
ps.setString(4, "Donne");
ps.executeUpdate();
}
ResultSet rs = s.executeQuery(
"SELECT count(*) FROM test_insert_multiple");
rs.next();
Assert.assertEquals(rs.getInt(1), 2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
Expand Down Expand Up @@ -559,6 +560,29 @@ public void testJsonResponseWithNull() throws SQLException {
}
}

@Test(groups = "integration")
public void testInsertMultiple() throws SQLException {
connection.createStatement().execute(
"DROP TABLE IF EXISTS test_insert_multiple_old_driver");
connection.createStatement().execute(
"CREATE TABLE IF NOT EXISTS test_insert_multiple_old_driver"
+ "(id UInt32, name String) "
+ "ENGINE = Memory");
try (PreparedStatement ps = connection.prepareStatement(
"INSERT INTO test_insert_multiple_old_driver VALUES (?, ?), (?, ?)")) {
ps.setInt(1, 1);
ps.setString(2, "John");
ps.setInt(3, 2);
ps.setString(4, "Donne");
ps.executeUpdate();
}

ResultSet rs = connection.createStatement().executeQuery(
"SELECT count(*) FROM test_insert_multiple_old_driver");
rs.next();
assertEquals(rs.getInt(1), 2);
}

private static String readQueryId(ClickHouseStatementImpl stmt, long timeoutSecs) {
long start = System.currentTimeMillis();
String value;
Expand Down