diff --git a/build.gradle b/build.gradle index 956b4989233a..d77dfb9ace8e 100644 --- a/build.gradle +++ b/build.gradle @@ -99,7 +99,7 @@ dependencies { // VersionEye states that 6.0.5 is the most recent version, but http://dev.mysql.com/downloads/connector/j/ shows that as "Development Release" compile 'mysql:mysql-connector-java:5.1.40' - compile 'com.impossibl.pgjdbc-ng:pgjdbc-ng:0.6' + compile 'org.postgresql:postgresql:9.4.1210' compile 'net.java.dev.glazedlists:glazedlists_java15:1.9.1' compile fileTree(dir: 'lib', includes: ['*.jar']) diff --git a/external-libraries.txt b/external-libraries.txt index c13f110ecc6e..50b8112da024 100644 --- a/external-libraries.txt +++ b/external-libraries.txt @@ -50,11 +50,6 @@ Project: java-diff-utils URL: https://github.com/bkromhout/java-diff-utils License: Apache-2.0 -Id: com.impossibl.pgjdbc-ng:pgjdbc-ng -Project: pgjdbc-ng -URL: http://impossibl.github.io/pgjdbc-ng -License: BSD - Id: com.jgoodies:jgoodies-common Project: JGoodies Common URL: http://www.jgoodies.com/downloads/libraries/ diff --git a/src/main/java/net/sf/jabref/shared/DBMSType.java b/src/main/java/net/sf/jabref/shared/DBMSType.java index d27b0af634a5..e96f567e5a8f 100644 --- a/src/main/java/net/sf/jabref/shared/DBMSType.java +++ b/src/main/java/net/sf/jabref/shared/DBMSType.java @@ -18,8 +18,8 @@ public enum DBMSType { "jdbc:oracle:thin:@%s:%d:%s", 1521), POSTGRESQL( "PostgreSQL", - "com.impossibl.postgres.jdbc.PGDriver", - "jdbc:pgsql://%s:%d/%s", 5432); + "org.postgresql.Driver", + "jdbc:postgresql://%s:%d/%s", 5432); private final String type; private final String driverPath; diff --git a/src/main/java/net/sf/jabref/shared/PostgreSQLProcessor.java b/src/main/java/net/sf/jabref/shared/PostgreSQLProcessor.java index 6a302d1a05cf..1191eb26cf0c 100644 --- a/src/main/java/net/sf/jabref/shared/PostgreSQLProcessor.java +++ b/src/main/java/net/sf/jabref/shared/PostgreSQLProcessor.java @@ -1,5 +1,6 @@ package net.sf.jabref.shared; +import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -8,22 +9,12 @@ import java.util.logging.Logger; import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.shared.listener.PostgresSQLNotificationListener; - -import com.impossibl.postgres.api.jdbc.PGConnection; -import com.impossibl.postgres.jdbc.PGDataSource; -import com.impossibl.postgres.jdbc.ThreadedHousekeeper; /** * Processes all incoming or outgoing bib data to PostgreSQL database and manages its structure. */ public class PostgreSQLProcessor extends DBMSProcessor { - private PGConnection pgConnection; - - private PostgresSQLNotificationListener listener; - - public PostgreSQLProcessor(DBMSConnection connection) { super(connection); } @@ -85,47 +76,4 @@ String escape(String expression) { return "\"" + expression + "\""; } - - @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); - } - } - - @Override - public void stopNotificationListener() { - try { - pgConnection.close(); - } catch (SQLException e) { - LOGGER.error("SQL Error: ", e); - } - } - - @Override - public void notifyClients() { - try { - pgConnection.createStatement().execute("NOTIFY jabrefLiveUpdate, '" + PROCESSOR_ID + "';"); - } catch (SQLException e) { - LOGGER.error("SQL Error: ", e); - } - } } diff --git a/src/main/java/net/sf/jabref/shared/listener/PostgresSQLNotificationListener.java b/src/main/java/net/sf/jabref/shared/listener/PostgresSQLNotificationListener.java deleted file mode 100644 index 449e1f21ed5c..000000000000 --- a/src/main/java/net/sf/jabref/shared/listener/PostgresSQLNotificationListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.sf.jabref.shared.listener; - -import net.sf.jabref.shared.DBMSProcessor; -import net.sf.jabref.shared.DBMSSynchronizer; - -import com.impossibl.postgres.api.jdbc.PGNotificationListener; - -/** - * A listener for PostgreSQL database notifications. - */ -public class PostgresSQLNotificationListener implements PGNotificationListener { - - private final DBMSSynchronizer dbmsSynchronizer; - - - public PostgresSQLNotificationListener(DBMSSynchronizer dbmsSynchronizer) { - this.dbmsSynchronizer = dbmsSynchronizer; - } - - @Override - public void notification(int processId, String channel, String payload) { - if (!payload.equals(DBMSProcessor.PROCESSOR_ID)) { - dbmsSynchronizer.pullChanges(); - } - } - -} \ No newline at end of file diff --git a/src/test/java/net/sf/jabref/shared/DBMSTypeTest.java b/src/test/java/net/sf/jabref/shared/DBMSTypeTest.java index 0ec8936fbbb6..bfe9c0c1e06b 100644 --- a/src/test/java/net/sf/jabref/shared/DBMSTypeTest.java +++ b/src/test/java/net/sf/jabref/shared/DBMSTypeTest.java @@ -20,7 +20,7 @@ public void testToString() { public void testGetDriverClassPath() { Assert.assertEquals("com.mysql.jdbc.Driver", DBMSType.MYSQL.getDriverClassPath()); Assert.assertEquals("oracle.jdbc.driver.OracleDriver", DBMSType.ORACLE.getDriverClassPath()); - Assert.assertEquals("com.impossibl.postgres.jdbc.PGDriver", DBMSType.POSTGRESQL.getDriverClassPath()); + Assert.assertEquals("org.postgresql.Driver", DBMSType.POSTGRESQL.getDriverClassPath()); } @Test @@ -35,7 +35,7 @@ public void testFromString() { public void testGetUrl() { Assert.assertEquals("jdbc:mysql://localhost:3306/xe", DBMSType.MYSQL.getUrl("localhost", 3306, "xe")); Assert.assertEquals("jdbc:oracle:thin:@localhost:1521:xe", DBMSType.ORACLE.getUrl("localhost", 1521, "xe")); - Assert.assertEquals("jdbc:pgsql://localhost:5432/xe", DBMSType.POSTGRESQL.getUrl("localhost", 5432, "xe")); + Assert.assertEquals("jdbc:postgresql://localhost:5432/xe", DBMSType.POSTGRESQL.getUrl("localhost", 5432, "xe")); } @Test