From da6b366397aa15e2686840c1d9ffa5dae5d49d2a Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sat, 16 Nov 2024 02:16:16 +0530 Subject: First Commit --- src/Store/ConnectionHandler.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Store/ConnectionHandler.java (limited to 'src/Store/ConnectionHandler.java') diff --git a/src/Store/ConnectionHandler.java b/src/Store/ConnectionHandler.java new file mode 100644 index 0000000..45d4446 --- /dev/null +++ b/src/Store/ConnectionHandler.java @@ -0,0 +1,28 @@ +package Store; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +public class ConnectionHandler { + String address; + public static Connection connection; + + public ConnectionHandler(String address) { + this.address = address; + } + + public void connect() { + try { + connection = DriverManager.getConnection(this.address); + + // create tables if they don't exist + Book.createTable(); + User.createTable(); + } catch (SQLException e) { + System.err.println(e.getMessage()); + } + } + + // TODO: disconnect +} -- cgit v1.2.3