I use gephi 0.9.2
on Windows. I can connect to my SQL Server (2016) via File - Import Database - Edge List
entering all parameters incl. username and password in the gui (this means connection via SQL Server authentication). I would like to connect to the database using integrated security ("Windows authentication"). I cannot find a way to enter the connection string or to give that information in any other way.
Is there any way in gephi 0.9.2 to define the connection string to a SQL Server directly?
This would do the job perfectly:
jdbc:sqlserver://server\instance;databaseName=DBName;integratedSecurity=true;
All I could find is a binary file "EdgeListDatabase" in my roaming profile. But this seems to only hold the data entered in the gui.
Here's how the connection is established (no other way than over the Edge List):
gephi/io/importer/plugin/database/ImporterEdgeList.java
private void importData() throws Exception {
//Connect database
String url = SQLUtils.getUrl(database.getSQLDriver(), database.getHost(), database.getPort(), database.getDBName());
try {
report.log("Try to connect at " + url);
connection = database.getSQLDriver().getConnection(url, database.getUsername(), database.getPasswd());
report.log("Database connection established");
}
This is how the connection string is formed by getUrl from the fields you pass in the Edge List: gephi/io/database/drivers/SQLUtils.java
public static String getUrl(SQLDriver driver, String host, int port, String dbname) {
String res = "jdbc:";
res += driver != null ? driver.getPrefix() : "";
res += "://";
res += host != null ? host : "";
res += ":";
res += port != 0 ? port : "";
res += dbname != null ? "/" + dbname : "";
return res;
}
That's how to final connection is established in the SQLServerDriver: gephi/modules/DBDrivers/src/main/java/org/gephi/io/database/drivers/SQLServerDriver.java
public Connection getConnection(String connectionUrl, String username, String passwd) throws SQLException {
//Bug #745414
if (!connectionUrl.contains(";databaseName=")) {
String dbname = connectionUrl.substring(connectionUrl.lastIndexOf('/') + 1);
String url = connectionUrl.substring(0, connectionUrl.lastIndexOf('/'));
connectionUrl = url + ";databaseName=" + dbname;
}
return DriverManager.getConnection(connectionUrl, username, passwd);
}
public static Connection getConnection(String url, String user, String password)
You might be able to make an injection over the host field if you set the host to:
server\instance;integratedSecurity=true;authenticationScheme=javakerberos;password=
You will bypass a syntax error from the inserted res += ":";
if you use it as password=:
Set the dbName as usual, leave port blank and set a dummy username and password.
Now you have to hope that the driver doesn't overrule the windows authentication, because you called getConnection with credentials.
If this doesn't work, your only way is to change the source of the ImporterEdgeList.java plugin to call getConnection(String url) and manually forge the url based on database.getHost() if the colon bypass doesn't work.
Something like that:
private void importData() throws Exception {
//Connect database
String url = "jdbc:";
url += driver != null ? database.getSQLDriver().getPrefix() : "sqlserver";
url += "://";
url += database.getHost();
try {
report.log("Try to connect at " + url);
connection = database.getSQLDriver().getConnection(url);
report.log("Database connection established");
}
With this hack you can specify the rest of the connection string over the host variable