Package webapp.sql

Source Code of webapp.sql.DirectConnection

package webapp.sql;

import webapp.WebAppException;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import static webapp.Config.*;

/**
* User: gkislin
* Date: 06.11.13
*/
public class DirectConnection implements ConnectionFactory {

    public DirectConnection()  {
        try {
            Class.forName("org.postgresql.Driver").newInstance();
        } catch (Exception e) {
            throw new WebAppException("Driver initialization exception", e);
        }
    }

    @Override
    public Connection getConnection() throws SQLException {
        return DriverManager.getConnection(
                DB_URL, DB_USER, DB_PASSWORD);
    }
}
TOP

Related Classes of webapp.sql.DirectConnection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.