Skip to content
Snippets Groups Projects
Commit 86d737d0 authored by joeappleton18's avatar joeappleton18
Browse files

finished solutions

parent d9f34647
No related branches found
No related tags found
No related merge requests found
package com.yatl; package com.yatl;
import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.yatl.util.Database;
import com.yatl.util.Seeder; import com.yatl.util.Seeder;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
new Seeder();
URL resourceFolderUrl = Main.class.getClassLoader().getResource("");
String databasePath = resourceFolderUrl.getPath() + "database.db";
String url = "jdbc:sqlite:" + databasePath;
Database db = Database.getInstance(url);
Connection conn = db.getConnection();
Statement stmt;
try {
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM todos");
while (rs.next()) {
System.out.println(rs.getInt("id") + " " + rs.getString("title") + " " + rs.getBoolean("completed"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
} }
...@@ -28,7 +28,7 @@ public class Database { ...@@ -28,7 +28,7 @@ public class Database {
} }
public Connection GetConnection() { public Connection getConnection() {
return connection; return connection;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment