You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Rob Stewart <ro...@googlemail.com> on 2011/02/27 22:41:06 UTC
JDBC Driver with Fuseki
Hi, I'm trying to connect my mySql database to Fuseki, but I'm having
difficulties. I have amended the final line of the file fuseki-server:
exec java -cp /usr/share/java/mysql-connector-java.jar -Xmx1200M -jar
"$JAR" "$@"
Here is my tdb.ttl file:
-------------------
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
<#dataSource> rdf:type ja:RDFDataset ;
rdfs:label "DSpaceImage" ;
ja:defaultGraph _:ProfileDatabase
.
_:ProfileDatabase rdf:type ja:RDBModel ;
ja:connection
[
ja:dbType "MySQL" ;
ja:dbURL "jdbc:mysql://localhost/TheDatase" ;
ja:dbUser "user" ;
ja:dbPassword "password" ;
ja:dbClass "com.mysql.jdbc.Driver" ;
] ;
ja:modelName "UserProfiles"
.
--------------------------
Now when I run:
./fuseki-server --desc tdb.ttl /dataSource
I get the error:
com.hp.hpl.jena.assembler.exceptions.CannotLoadClassException: the
class 'com.mysql.jdbc.Driver' required by the object.... .... could
not be loaded.
Thanks,
--
Rob
Re: JDBC Driver with Fuseki
Posted by Damian Steer <d....@bristol.ac.uk>.
On 27 Feb 2011, at 21:41, Rob Stewart wrote:
> Hi, I'm trying to connect my mySql database to Fuseki, but I'm having
> difficulties. I have amended the final line of the file fuseki-server:
Hi Rob,
> exec java -cp /usr/share/java/mysql-connector-java.jar -Xmx1200M -jar
> "$JAR" "$@"
Yeah, one of the most annoying gotchas in java. if you use '-jar' it ignores the classpath. Try:
exec java -cp /usr/share/java/mysql-connector-java.jar -Xmx1200M -cp "$JAR" org.openjena.fuseki.FusekiCmd "$@"
(or something like that)
Damian
Re: JDBC Driver with Fuseki
Posted by Andy Seaborne <an...@epimorphics.com>.
On 27/02/11 21:41, Rob Stewart wrote:
> Hi, I'm trying to connect my mySql database to Fuseki, but I'm having
> difficulties. I have amended the final line of the file fuseki-server:
>
> exec java -cp /usr/share/java/mysql-connector-java.jar -Xmx1200M -jar
> "$JAR" "$@"
-jar takes the classpath from inside the jarfile. I think -cp is
ignored. You'll have to unpack the jar and making a classpath with the
unpacked classes and the JDBC driver for MySQL.
>
> Here is my tdb.ttl file:
> -------------------
>
> @prefix tdb:<http://jena.hpl.hp.com/2008/tdb#> .
> @prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> .
> @prefix ja:<http://jena.hpl.hp.com/2005/11/Assembler#> .
> @prefix tdb:<http://jena.hpl.hp.com/2008/tdb#> .
>
> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
Err - that's for TDB, and you want SDB.
http://openjena.org/wiki/SDB
> tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
> tdb:GraphTDB rdfs:subClassOf ja:Model .
>
>
> <#dataSource> rdf:type ja:RDFDataset ;
> rdfs:label "DSpaceImage" ;
> ja:defaultGraph _:ProfileDatabase
> .
>
> _:ProfileDatabase rdf:type ja:RDBModel ;
> ja:connection
> [
> ja:dbType "MySQL" ;
> ja:dbURL "jdbc:mysql://localhost/TheDatase" ;
> ja:dbUser "user" ;
> ja:dbPassword "password" ;
> ja:dbClass "com.mysql.jdbc.Driver" ;
> ] ;
> ja:modelName "UserProfiles"
We do not recommend the use of RDB unless it's for legacy databases.
Andy
> .
> --------------------------
>
> Now when I run:
> ./fuseki-server --desc tdb.ttl /dataSource
>
> I get the error:
> com.hp.hpl.jena.assembler.exceptions.CannotLoadClassException: the
> class 'com.mysql.jdbc.Driver' required by the object.... .... could
> not be loaded.
>
> Thanks,
>
> --
> Rob