@@ -0,0 +1,2197 @@
+/*%0A * Copyright 2015 Ryan Gilera.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.github.daytron.revworks.service;%0A%0Aimport com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;%0Aimport java.sql.SQLException;%0A%0A/**%0A * A singleton class for establishing connection to the database.%0A *%0A * @author Ryan Gilera%0A */%0Apublic class SQLConnectionManager %7B%0A%0A    private static final long serialVersionUID = 1L;%0A%0A    private SimpleJDBCConnectionPool jbdcConnectionPool = null;%0A%0A    private SQLConnectionManager() %7B%0A    %7D%0A%0A    /**%0A     * Returns the one and only one object of this class%0A     * %0A     * @return SQLConnectionManager object%0A     */%0A    public static SQLConnectionManager getInstance() %7B%0A        return SQLConnectionManagerHolder.INSTANCE;%0A    %7D%0A%0A    /**%0A     * Returns %7B@link SimpleJDBCConnectionPool%7D object. Creates a new object if%0A     * no object is attached.%0A     *%0A     * @return SimpleJDBCConnectionPool object%0A     * @throws SQLException occurs whenever something went wrong to the database %0A     * connection%0A     */%0A    public SimpleJDBCConnectionPool connect() throws SQLException %7B%0A        if (jbdcConnectionPool == null) %7B%0A            jbdcConnectionPool = new SimpleJDBCConnectionPool(%0A                    %22com.mysql.jdbc.Driver%22,%0A                    %22jdbc:mysql://localhost/appschema%22,%0A                    %22uservalidator%22, %22sqluserpw%22, 2, 10);%0A        %7D%0A%0A        return jbdcConnectionPool;%0A    %7D%0A%0A    /**%0A     * A private inner class that serves as a singleton object container %0A     */%0A    private static class SQLConnectionManagerHolder %7B%0A%0A        private static final SQLConnectionManager INSTANCE = new SQLConnectionManager();%0A    %7D%0A%7D%0A

Refactor SQL database connection to a separate singleton class