@@ -0,0 +1,3263 @@
+package edu.pdx.cs510.agile.team3.db;%0A%0Aimport java.sql.*;%0A%0Apublic class DBManager %7B%0A%0A    private static String connectionString = %22jdbc:sqlite:src/sql/saved_connections.db%22;%0A    private static Connection connection;%0A%0A    public static void connect() throws SQLException %7B%0A        try %7B%0A            Class.forName(%22org.sqlite.JDBC%22);%0A            connection = DriverManager.getConnection(connectionString);%0A            DatabaseMetaData meta = connection.getMetaData();%0A            // Check if table already exists%0A            ResultSet results = meta.getTables(null, null, %22connections%22, null);%0A            if (!results.next()) %7B%0A                initialize();%0A            %7D%0A        %7D catch(ClassNotFoundException e) %7B%0A            System.err.println(e.getMessage());%0A        %7D%0A    %7D%0A%0A    public static void close() %7B%0A        try %7B%0A            connection.close();%0A        %7D catch (SQLException e) %7B%0A            System.err.println(e.getMessage());%0A        %7D%0A    %7D%0A%0A    // Input is not sanitized! Have fun!%0A    public static boolean saveConnection(String user,%0A                                      String pass,%0A                                      String host) throws SQLException %7B%0A        String sql = null;%0A        if(checkIfExists(user)) %7B%0A            if(!login(user, pass)) %7B%0A                return false;%0A            %7D%0A            sql = %22UPDATE connections set pass = '%22 + pass + %22', %22 +%0A                    %22host = '%22 + host + %22' WHERE user = '%22 + user + %22';%22;%0A        %7D else %7B%0A            sql = %22INSERT INTO connections (user, pass, host) %22 +%0A                    %22VALUES ('%22 + user + %22', '%22 + pass + %22', '%22 + host + %22');%22;%0A        %7D%0A        Statement statement = connection.createStatement();%0A        statement.executeUpdate(sql);%0A        statement.close();%0A        return true;%0A    %7D%0A%0A%0A    public static boolean login(String user,%0A                               String pass) throws SQLException %7B%0A        Statement statement = connection.createStatement();%0A        String sql = %22SELECT host FROM connections %22 +%0A                %22WHERE user = '%22 + user + %22' AND pass = '%22 + pass + %22';%22;%0A        ResultSet results = statement.executeQuery(sql);%0A        boolean valid = false;%0A        if(results.next()) %7B%0A            valid = true;%0A        %7D%0A        results.close();%0A        statement.close();%0A        return valid;%0A    %7D%0A%0A    private static void initialize() throws SQLException %7B%0A        Statement statement = connection.createStatement();%0A        String sql = %22CREATE TABLE connections (%22 +%0A                %22id      INTEGER PRIMARY KEY AUTOINCREMENT,%22 +%0A                %22user    VARCHAR NOT NULL,%22 +%0A                %22pass    VARCHAR NOT NULL,%22 +%0A                %22host    VARCHAR NOT NULL%22 +%0A                %22);%22;%0A        statement.executeUpdate(sql);%0A        statement.close();%0A    %7D%0A%0A    private static boolean checkIfExists(String user) throws SQLException %7B%0A        Statement statement = connection.createStatement();%0A        String sql = %22SELECT * FROM connections %22 +%0A                %22WHERE user = '%22 + user + %22';%22;%0A        ResultSet results = statement.executeQuery(sql);%0A        boolean exists = false;%0A        if(results.next()) %7B%0A            exists = true;%0A        %7D%0A        results.close();%0A        statement.close();%0A        return exists;%0A    %7D%0A%7D%0A

Add prototype database manager