|
1 | 1 | package com.clickhouse.jdbc;
|
2 | 2 |
|
3 | 3 | import java.io.ByteArrayInputStream;
|
| 4 | +import java.math.BigDecimal; |
4 | 5 | import java.net.Inet4Address;
|
5 | 6 | import java.net.Inet6Address;
|
| 7 | +import java.net.URL; |
6 | 8 | import java.nio.charset.StandardCharsets;
|
7 | 9 | import java.sql.BatchUpdateException;
|
8 | 10 | import java.sql.Connection;
|
@@ -1257,4 +1259,46 @@ public void testInsertWithAndSelect() throws Exception {
|
1257 | 1259 | Assert.assertFalse(rs.next());
|
1258 | 1260 | }
|
1259 | 1261 | }
|
| 1262 | + |
| 1263 | + @Test(groups = "integration") |
| 1264 | + public void testInsertWithMultipleValues() throws Exception { |
| 1265 | + try (ClickHouseConnection conn = newConnection(new Properties()); |
| 1266 | + Statement s = conn.createStatement()) { |
| 1267 | + s.execute("drop table if exists test_insert_with_multiple_values; " |
| 1268 | + + "CREATE TABLE test_insert_with_multiple_values(a Int32, b Nullable(String)) ENGINE=Memory"); |
| 1269 | + try (PreparedStatement ps = conn.prepareStatement( |
| 1270 | + "INSERT INTO test_insert_with_multiple_values values(?, ?), (2 , ? ), ( ? , '') , (?,?) ,( ? ,? )")) { |
| 1271 | + ps.setInt(1, 1); |
| 1272 | + ps.setNull(2, Types.VARCHAR); |
| 1273 | + ps.setObject(3, "er"); |
| 1274 | + ps.setInt(4, 3); |
| 1275 | + ps.setInt(5, 4); |
| 1276 | + ps.setURL(6, new URL("http://some.host")); |
| 1277 | + ps.setInt(7, 5); |
| 1278 | + ps.setString(8, null); |
| 1279 | + ps.executeUpdate(); |
| 1280 | + } |
| 1281 | + |
| 1282 | + try (ResultSet rs = s.executeQuery("select * from test_insert_with_multiple_values order by a")) { |
| 1283 | + Assert.assertTrue(rs.next()); |
| 1284 | + Assert.assertEquals(rs.getByte(1), (byte) 1); |
| 1285 | + Assert.assertEquals(rs.getObject(2), null); |
| 1286 | + Assert.assertTrue(rs.wasNull()); |
| 1287 | + Assert.assertTrue(rs.next()); |
| 1288 | + Assert.assertEquals(rs.getBigDecimal(1), BigDecimal.valueOf(2L)); |
| 1289 | + Assert.assertEquals(rs.getString(2), "er"); |
| 1290 | + Assert.assertTrue(rs.next()); |
| 1291 | + Assert.assertEquals(rs.getString(1), "3"); |
| 1292 | + Assert.assertEquals(rs.getObject(2), ""); |
| 1293 | + Assert.assertTrue(rs.next()); |
| 1294 | + Assert.assertEquals(rs.getShort(1), (short) 4); |
| 1295 | + Assert.assertEquals(rs.getURL(2), new URL("http://some.host")); |
| 1296 | + Assert.assertTrue(rs.next()); |
| 1297 | + Assert.assertEquals(rs.getObject(1), Integer.valueOf(5)); |
| 1298 | + Assert.assertEquals(rs.getString(2), null); |
| 1299 | + Assert.assertTrue(rs.wasNull()); |
| 1300 | + Assert.assertFalse(rs.next()); |
| 1301 | + } |
| 1302 | + } |
| 1303 | + } |
1260 | 1304 | }
|
0 commit comments