1 package net.jaekl.cfb.db.driver;
3 // Copyright (C) 2015 Christian Jaekl
5 import java.sql.Connection;
6 import java.sql.DriverManager;
7 import java.sql.SQLException;
8 import java.util.Properties;
10 public class PostgresqlDriver extends DbDriver {
13 public void load() throws ClassNotFoundException {
14 // This should no longer be necessary, so long as we're using
15 // JDBC 4 (which came out with JDK 6) and an updated driver.
16 // But, it shouldn't hurt, either.
17 Class.forName("org.postgresql.Driver");
21 public Connection connect(String host, int port, String dbName, String user, String pass) throws SQLException {
22 String url = "jdbc:postgresql://" + host + ":" + port + "/" + dbName;
23 Properties props = new Properties();
24 props.setProperty("user", user);
25 props.setProperty("password", pass);
26 //props.setProperty("ssl", "true");
27 return DriverManager.getConnection(url, props);