mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-12-23 08:21:09 +00:00
Add multi select test in JDBC4StatementTest
This commit is contained in:
parent
b07e95b892
commit
c8bb2e73ec
1 changed files with 25 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package tech.turso.jdbc4;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
|
@ -55,6 +56,30 @@ class JDBC4StatementTest {
|
|||
assertTrue(stmt.execute("SELECT * FROM users;"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void execute_select() throws Exception {
|
||||
stmt.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT);");
|
||||
stmt.execute("INSERT INTO users VALUES (1, 'turso 1')");
|
||||
stmt.execute("INSERT INTO users VALUES (2, 'turso 2')");
|
||||
stmt.execute("INSERT INTO users VALUES (3, 'turso 3')");
|
||||
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users;");
|
||||
rs.next();
|
||||
int rowCount = 0;
|
||||
|
||||
do {
|
||||
rowCount++;
|
||||
int id = rs.getInt(1);
|
||||
String username = rs.getString(2);
|
||||
|
||||
assertEquals(id, rowCount);
|
||||
assertEquals(username, "turso " + rowCount);
|
||||
} while (rs.next());
|
||||
|
||||
assertEquals(rowCount, 3);
|
||||
assertFalse(rs.next());
|
||||
}
|
||||
|
||||
@Test
|
||||
void close_statement_test() throws Exception {
|
||||
stmt.close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue