aboutsummaryrefslogtreecommitdiff
path: root/src/Store/ConnectionHandler.java
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2024-11-16 02:16:16 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2024-11-16 02:16:16 +0530
commitda6b366397aa15e2686840c1d9ffa5dae5d49d2a (patch)
treea53bc42092a564bfbf66a67b70e3aa9cb8689798 /src/Store/ConnectionHandler.java
First Commit
Diffstat (limited to 'src/Store/ConnectionHandler.java')
-rw-r--r--src/Store/ConnectionHandler.java28
1 files changed, 28 insertions, 0 deletions
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
+}