mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-07 12:35:00 +00:00
Merge 'Add multi select test in JDBC4StatementTest' from Kim Seon Woo
In reponse to [discord discussion](https://discord.com/channels/12586588 26257961020/1385754749634084885/1390535068401012858), I thought it would be better to add a test to show how JDBC4Statement can be used. Closes #1962
This commit is contained in:
commit
a833f9e33a
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