package util;

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

public class Conexao {

	private static Connection connection;

	private static String driver = "org.postgresql.Driver";

	//private static String password = "admin";
	private static String password = "postgres08";   // Ismaelīs laptop
	
	private static String url = "jdbc:postgresql://localhost/academicNet";

	private static String user = "postgres";

	public Connection conectar() {
		try {
			Class.forName(driver);
			connection = DriverManager.getConnection(url, user, password);
		} catch (ClassNotFoundException cnfe) {
			System.out.println(cnfe.getMessage());
		} catch (SQLException sqle) {
			System.out.println(sqle.getMessage());
		}
		return connection;
	}

	public void desconectar(Connection connection) {
		try {
			connection.close();
		} catch (SQLException sqle) {
			System.out.println(sqle.getMessage());
		}
	}

}