aboutsummaryrefslogtreecommitdiff
path: root/src/Store/ConnectionHandler.java
blob: 45d44464e9fac43a3071108ce660e0c4ee156853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}