← Back to team overview

gephi.team team mailing list archive

Re: [Question #147581]: writing a DB connector plugin

 

Question #147581 on Gephi changed:
https://answers.launchpad.net/gephi/+question/147581

    Status: Open => Answered

Mathieu Bastian proposed the following answer:
Following my previous answer you might have the module with the JAR. The
SQLDriver implementation are basically almost the same as others (e.g.
MySQL). The prefix should be what is in the JDBC URL.

@ServiceProvider(service=SQLDriver.class)
public class NewDriver implements SQLDriver {

    public Connection getConnection(String connectionUrl, String username, String passwd) throws SQLException {
        return DriverManager.getConnection(connectionUrl, username, passwd);
    }

    @Override
    public String getPrefix() {
        return "newdriver";
    }

    @Override
    public String toString() {
        return "New Driver";
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof MySQLDriver) {
            return ((NewDriver) obj).getPrefix().equals(getPrefix());
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return getPrefix().hashCode();
    }
}

-- 
You received this question notification because you are a member of
Gephi Team, which is an answer contact for Gephi.