diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2024-11-16 02:16:16 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2024-11-16 02:16:16 +0530 |
commit | da6b366397aa15e2686840c1d9ffa5dae5d49d2a (patch) | |
tree | a53bc42092a564bfbf66a67b70e3aa9cb8689798 /src/Store/ConnectionHandler.java |
First Commit
Diffstat (limited to 'src/Store/ConnectionHandler.java')
-rw-r--r-- | src/Store/ConnectionHandler.java | 28 |
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 +} |