nkons / r2rml-parser

R2RML Parser is an award-winning tool that can export relational database contents as RDF graphs, based on an R2RML mapping document.
Apache License 2.0
68 stars 21 forks source link

Error establishing source (relational) connection! #26

Open damilolah opened 6 years ago

damilolah commented 6 years ago

Mysql example

db.url=jdbc:mysql://127.0.0.1:3306/clean_data db.login=root db.password=pass db.driver=mysql-connector-java-5.1.18-bin.jar

db.driver=lib/mysql-connector-java-5.1.28.jar

db.driver=com.mysql.jdbc.Driver

I'm getting this in my status.log file; Error establishing source (relational) connection! Please check your connection settings.

Please is something wrong with my connection settings above. Also, what is the correct input to db.driver. Thanks.

nkons commented 6 years ago

Hi, the correct input to db.driver for mysql is

db.driver=com.mysql.jdbc.Driver
damilolah commented 6 years ago

Thanks for your reply. My connection settings now look like this:

db.url=jdbc:mysql://localhost:3306/clean_data db.login=root db.password=passwd db.driver=com.mysql.jdbc.Driver

I've corrected that but still I'm getting this in my status.log file; Error establishing source (relational) connection! Please check your connection settings.

The database exist and I can query it but I wonder why connection cannot be established.

ConstantinHildebrandt commented 5 years ago

Hey,

I am facing the exact same issue. Was there a solution in the meanwhile?

My r2rml.properties is: db.url=jdbc:mysql://localhost:3306/sakila db.login=root db.password=123456 db.driver=com.mysql.jdbc.Driver

I can establish a connection via MySQL Workbench with the abovementioned login credentials and I can query the sakila database (e.g. table "actor"). However, I still get the error: "2019-03-25 13:16:52,567 ERROR [Database] Error establishing source (relational) connection! Please check your connection settings."

I am using a Win10 x86 device with mysql community version 5.5.

Thanks!

EDIT: I updated to MySQL Server 8.0.15 with Connector/J 8.0.15, still facing the same issue.

EDIT TO EDIT: When I use the source code and update the JDBC Connector to version 8.0.14 and use the following db info:

String user = "?user=root"; String password = "&password=123456"; String url = "jdbc:mysql://localhost/sakila"; String conf = &useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";

Then I can at least establish a connection to the DB, however, then I get the following error:

java.lang.StringIndexOutOfBoundsException: begin 7, end -1, length 7 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319) at java.base/java.lang.String.substring(String.java:1874) at gr.seab.r2rml.entities.sql.SelectQuery.createSelectFields(SelectQuery.java:61) at gr.seab.r2rml.entities.sql.SelectQuery.(SelectQuery.java:34) at gr.seab.r2rml.beans.Parser.findLogicalTableMappings(Parser.java:501) at gr.seab.r2rml.beans.Parser.parse(Parser.java:106) at gr.seab.r2rml.beans.Main.main(Main.java:83) Exception in thread "main" java.lang.NullPointerException at gr.seab.r2rml.beans.Generator.createTriples(Generator.java:189) at gr.seab.r2rml.beans.Main.main(Main.java:93)

ConstantinHildebrandt commented 5 years ago

So I solved the issue, but it requires changes to the source code in order to run with MySQL version > 5.5.

I did the following:

Lastly, I am not sure whether that is just specific to my MySQL instance, however, I had to change the strings that is used to establish the MySQL server connection to:

connection = DriverManager.getConnection(url + user + password + conf);

    String user = "?user=root";
    String password = "&password=1234";
    String url = "jdbc:mysql://localhost/sakila";
    String conf = "&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";

The java exception I got from above, was just because the sakila DB, which is used as MySQL example DB which is created by default on install, does not look as it is modelled in the R2RML mapping file. So by adjusting the example mapping to the actual example data, it works just fine.

Regards, Constantin

nkons commented 5 years ago

Hi,

Happy to hear this works now.

Thanks for posting your solution here. This is likely to be helpful to other Mysql users as well.

Best, Nikos