@@ -0,0 +1,2252 @@
+package database;%0A%0A/**%0A * A simple class that calls the database.%0A *%0A * Created by alex on 9/18/15.%0A */%0A%0Aimport java.sql.*;%0Aimport java.util.ArrayList;%0A%0Apublic class Database %7B%0A    // JDBC driver name and database URL%0A    static final String JDBC_DRIVER = %22com.mysql.jdbc.Driver%22;%0A    static final String DB_URL = %22jdbc:mysql://localhost/ProjectX%22;%0A%0A    //  Database credentials%0A    static final String USER = %22root%22;%0A    static final String PASS = %22root%22;%0A%0A    //Replace with connection pool if needed.%0A    private Connection conn;%0A    private Statement stmt;%0A%0A    public Database() %7B%0A        Connection conn = null;%0A        Statement stmt = null;%0A        try %7B%0A            //Register JDBC driver%0A            Class.forName(%22com.mysql.jdbc.Driver%22);%0A%0A            //Open a connection%0A            conn = DriverManager.getConnection(DB_URL, USER, PASS);%0A%0A        %7D catch (SQLException se) %7B%0A            //Handle errors for JDBC%0A            se.printStackTrace();%0A        %7D catch (Exception e) %7B%0A            //Handle errors for Class.forName%0A            e.printStackTrace();%0A        %7D%0A%0A    %7D%0A%0A    /**%0A     * @return A string with a to tep scoreboard.%0A     */%0A    public String getGolbalTopTen() %7B%0A        try %7B%0A            ResultSet rs = stmt.executeQuery(%22CALL getGlobalTopTen;%22);%0A            StringBuilder sb = new StringBuilder();%0A            for (int i = 1; rs.next(); i++) %7B%0A                sb.append(i + %22. %22);%0A                sb.append(rs.getString(%22nickname%22));%0A                sb.append(%22 %22);%0A                sb.append(rs.getInt(%22score%22));%0A                sb.append(%22%5Cn%22);%0A            %7D%0A            //Close the statement. TODO: Check if really needed.%0A            rs.close();%0A            stmt.close();%0A            return sb.toString();%0A%0A        %7D catch (SQLException e) %7B%0A            e.printStackTrace();%0A            //Well this is not best practices...%0A            return %22%22;%0A        %7D%0A    %7D%0A%0A    public void closeConnection() %7B%0A        try %7B%0A            if (stmt != null)%0A                stmt.close();%0A        %7D catch (SQLException se) %7B%0A            se.printStackTrace();%0A        %7D%0A        try %7B%0A            if (conn != null)%0A                conn.close();%0A        %7D catch (SQLException se) %7B%0A            se.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A%0A%0A

Add small database interface class.