use of org.postgresql.Driver in project teiid by teiid.
the class TestODBCSocketTransport method testSelectSsl.
@Test
public void testSelectSsl() throws Exception {
conn.close();
Driver d = new Driver();
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
p.setProperty("ssl", "true");
p.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory");
conn = d.connect("jdbc:postgresql://" + odbcServer.addr.getHostName() + ":" + odbcServer.odbcTransport.getPort() + "/parts", p);
Statement s = conn.createStatement();
assertTrue(s.execute("select * from sys.tables order by name"));
TestMMDatabaseMetaData.compareResultSet("TestODBCSocketTransport/testSelect", s.getResultSet());
}
use of org.postgresql.Driver in project YCSB by brianfrankcooper.
the class PostgreNoSQLDBClientTest method setUp.
@BeforeClass
public static void setUp() {
// Check whether postgres is available
try (Socket socket = new Socket(HOST_NAME, DEFAULT_PORT)) {
assertThat("Socket is not bound.", socket.getLocalPort(), not(-1));
} catch (IOException connectFailed) {
assumeNoException("PostgreSQL is not running. Skipping tests.", connectFailed);
}
Properties props = new Properties();
props.setProperty(PostgreNoSQLDBClient.CONNECTION_URL, TEST_DB_URL);
props.setProperty(PostgreNoSQLDBClient.CONNECTION_USER, DEFAULT_USER);
props.setProperty(PostgreNoSQLDBClient.CONNECTION_PASSWD, DEFAULT_PWD);
props.setProperty("user", DEFAULT_USER);
props.setProperty("password", DEFAULT_PWD);
props.setProperty(PostgreNoSQLDBClient.JDBC_AUTO_COMMIT, "true");
try {
postgreSQLConnection = new Driver().connect(TEST_DB_URL, props);
boolean tableExists = postgreSQLConnection.getMetaData().getTables(null, null, TABLE_NAME, null).next();
assertThat("Table does not exist.", tableExists, not(false));
postgreNoSQLClient = new PostgreNoSQLDBClient();
postgreNoSQLClient.setProperties(props);
postgreNoSQLClient.init();
} catch (PSQLException e) {
if (e.getSQLState().equals("3D000")) {
assumeNoException("Database does not exist. Skipping tests.", e);
}
} catch (SQLException | DBException e) {
LOG.info(e.toString());
}
}
use of org.postgresql.Driver in project YCSB by brianfrankcooper.
the class PostgreNoSQLDBClient method init.
@Override
public void init() throws DBException {
INIT_COUNT.incrementAndGet();
synchronized (PostgreNoSQLDBClient.class) {
if (postgrenosqlDriver != null) {
return;
}
Properties props = getProperties();
String urls = props.getProperty(CONNECTION_URL, DEFAULT_PROP);
String user = props.getProperty(CONNECTION_USER, DEFAULT_PROP);
String passwd = props.getProperty(CONNECTION_PASSWD, DEFAULT_PROP);
boolean autoCommit = getBoolProperty(props, JDBC_AUTO_COMMIT, true);
try {
Properties tmpProps = new Properties();
tmpProps.setProperty("user", user);
tmpProps.setProperty("password", passwd);
cachedStatements = new ConcurrentHashMap<>();
postgrenosqlDriver = new Driver();
connection = postgrenosqlDriver.connect(urls, tmpProps);
connection.setAutoCommit(autoCommit);
} catch (Exception e) {
LOG.error("Error during initialization: " + e);
}
}
}
use of org.postgresql.Driver in project teiid by teiid.
the class TestODBCSSL method testLogin.
@Test(expected = SQLException.class)
public void testLogin() throws Exception {
odbcServer.start(Mode.LOGIN);
Driver d = new Driver();
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
d.connect("jdbc:postgresql://" + odbcServer.addr.getHostName() + ":" + odbcServer.odbcTransport.getPort() + "/parts", p);
}
use of org.postgresql.Driver in project teiid by teiid.
the class TestODBCSSL method testSelectSsl.
@Test
public void testSelectSsl() throws Exception {
odbcServer.start(Mode.ENABLED);
Driver d = new Driver();
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
p.setProperty("ssl", "true");
p.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory");
Connection conn = d.connect("jdbc:postgresql://" + odbcServer.addr.getHostName() + ":" + odbcServer.odbcTransport.getPort() + "/parts", p);
Statement s = conn.createStatement();
assertTrue(s.execute("select * from sys.tables order by name"));
TestMMDatabaseMetaData.compareResultSet("TestODBCSocketTransport/testSelect", s.getResultSet());
p.remove("ssl");
try {
conn = d.connect("jdbc:postgresql://" + odbcServer.addr.getHostName() + ":" + odbcServer.odbcTransport.getPort() + "/parts", p);
fail("should require ssl");
} catch (SQLException e) {
}
}
Aggregations