use of com.impossibl.postgres.jdbc.PGDataSource in project opennms by OpenNMS.
the class TestLoadDbNotifierDataSourceFactory method testLoadFromProperties.
@Test
public void testLoadFromProperties() {
System.out.println("start of testLoadFromProperties");
DbNotifierDataSourceFactory dsConfig = new DbNotifierDataSourceFactory();
dsConfig.setDataBaseName("testdataBaseName");
dsConfig.setUserName("testuserName");
dsConfig.setPassWord("testpassWord");
dsConfig.setHostname("localhost");
dsConfig.setPort("5432");
dsConfig.init();
assertEquals("testdataBaseName", dsConfig.getDataBaseName());
assertEquals("testuserName", dsConfig.getUserName());
assertEquals("testpassWord", dsConfig.getPassWord());
assertEquals("localhost", dsConfig.getHostname());
assertEquals("5432", dsConfig.getPort());
PGDataSource pgds = dsConfig.getPGDataSource();
assertNotNull(pgds);
System.out.println("end of testLoadFromProperties");
}
use of com.impossibl.postgres.jdbc.PGDataSource in project opennms by OpenNMS.
the class TestLoadDbNotifierDataSourceFactory method testLoadFromXML.
@Test
public void testLoadFromXML() {
System.out.println("start of testLoadFromXML");
DbNotifierDataSourceFactory dsConfig = new DbNotifierDataSourceFactory();
String fileUri = null;
fileUri = "./src/test/resources/opennms-datasources.xml";
dsConfig.setDataSourceFileUri(fileUri);
dsConfig.init();
assertEquals("opennms", dsConfig.getDataBaseName());
assertEquals("opennms", dsConfig.getUserName());
assertEquals("opennms", dsConfig.getPassWord());
assertEquals("localhost", dsConfig.getHostname());
assertEquals("5432", dsConfig.getPort());
PGDataSource pgds = dsConfig.getPGDataSource();
assertNotNull(pgds);
System.out.println("end of testLoadFromXML");
}
use of com.impossibl.postgres.jdbc.PGDataSource in project opennms by OpenNMS.
the class DbNotifierDataSourceFactory method getPGDataSource.
public PGDataSource getPGDataSource() {
PGDataSource pgdc = new PGDataSource();
pgdc.setHost(hostname);
pgdc.setPort(port);
pgdc.setDatabase(dataBaseName);
pgdc.setUser(userName);
pgdc.setPassword(passWord);
return pgdc;
}
use of com.impossibl.postgres.jdbc.PGDataSource in project camel by apache.
the class IntegrationTest method setUp.
@Before
public void setUp() throws Exception {
this.host = System.getProperty("pgjdbc.test.server", "localhost");
this.port = System.getProperty("pgjdbc.test.port", "5432");
this.database = System.getProperty("pgjdbc.test.db", "event_tests");
this.user = System.getProperty("pgjdbc.test.user", "dphillips");
this.password = System.getProperty("pgjdbc.test.password");
ds = new PGDataSource();
ds.setHost(this.host);
ds.setPort(Integer.parseInt(this.port));
ds.setDatabase(this.database);
ds.setUser(this.user);
if (this.password != null) {
ds.setPassword(this.password);
}
main = new Main();
main.bind("test", ds);
main.addRouteBuilder(buildConsumer());
main.addRouteBuilder(buildProducer());
}
use of com.impossibl.postgres.jdbc.PGDataSource in project jabref by JabRef.
the class PostgreSQLProcessor method startNotificationListener.
@Override
public void startNotificationListener(DBMSSynchronizer dbmsSynchronizer) {
// Disable cleanup output of ThreadedHousekeeper
Logger.getLogger(ThreadedHousekeeper.class.getName()).setLevel(Level.SEVERE);
this.listener = new PostgresSQLNotificationListener(dbmsSynchronizer);
PGDataSource dataSource = new PGDataSource();
dataSource.setHost(connectionProperties.getHost());
dataSource.setPort(connectionProperties.getPort());
dataSource.setDatabase(connectionProperties.getDatabase());
dataSource.setUser(connectionProperties.getUser());
dataSource.setPassword(connectionProperties.getPassword());
try {
pgConnection = (PGConnection) dataSource.getConnection();
pgConnection.createStatement().execute("LISTEN jabrefLiveUpdate");
// Do not use `new PostgresSQLNotificationListener(...)` as the object has to exist continuously!
// Otherwise the listener is going to be deleted by GC.
pgConnection.addNotificationListener(listener);
} catch (SQLException e) {
LOGGER.error("SQL Error: ", e);
}
}
Aggregations