test query
This commit is contained in:
parent
b70127865e
commit
b14c87f0c9
|
@ -1,10 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="/home/local/Downloads/sqlite-jdbc-3.43.2.2.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/home/local/Downloads/slf4j-api-1.7.36.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import java.sql.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
try (Connection conn = DriverManager.getConnection("jdbc:sqlite:/home/local/sqlite-test.db")) {
|
||||
System.out.println("Connection successful.");
|
||||
PreparedStatement s = conn.prepareStatement("SELECT * FROM test;");
|
||||
ResultSet r = s.executeQuery();
|
||||
while (r.next()) {
|
||||
System.out.println(r.getInt("id") + " | " + r.getString("name"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue