Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Dec 8, 2016
1 parent 5edc49b commit 54fe85b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 90 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
5 changes: 0 additions & 5 deletions external-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/shared/DBMSType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
54 changes: 1 addition & 53 deletions src/main/java/net/sf/jabref/shared/PostgreSQLProcessor.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/java/net/sf/jabref/shared/DBMSTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 54fe85b

Please sign in to comment.