我有以下问题:
当我尝试将文件的内容加载到我的模型中时,它会抛出异常,我不知道为什么会抛出它并且它会提供一大块带有语法失败的SQL。 任何人都可以帮我这个吗?
我检查了jdbc连接,但似乎没问题。 我将1.3.5 Jena SDB与play 2.2.0结合使用。然后应该使用mode =“mysql”play将模型持久化到h2数据库。
抛出异常的代码:
ds = SDBFactory.connectDataset(store);
Logger.debug("load default model");
model = ds.getDefaultModel();
Logger.debug("Loaded model");
FileManager.get().readModel(
model,
new File(rdfFile.getParentFile().getCanonicalPath()
.concat("/dataversions/" + datasetName)
+ ".txt").getCanonicalPath(), "N-TRIPLES");
Logger.debug("Filemanager loaded file into model...");
抛出的异常:
[debug] application - Create the new Dataset: test
[debug] application - load default model
[debug] application - Loaded model
[error] c.h.h.j.s.l.LoaderTuplesNodes - Error in thread: Problem making new tupleloader
com.hp.hpl.jena.sdb.SDBException: Problem making new tupleloader
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.updateOneTuple(LoaderTuplesNodes.java:292) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.access$200(LoaderTuplesNodes.java:43) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes$Commiter.run(LoaderTuplesNodes.java:362) ~[jena-sdb-1.3.5.jar:1.3.5]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_45]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_45]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.updateOneTuple(LoaderTuplesNodes.java:288) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.access$200(LoaderTuplesNodes.java:43) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes$Commiter.run(LoaderTuplesNodes.java:362) ~[jena-sdb-1.3.5.jar:1.3.5]
Caused by: com.hp.hpl.jena.sdb.SDBException: Problem initialising loader for [Triples]
at com.hp.hpl.jena.sdb.layout2.TupleLoaderBase.<init>(TupleLoaderBase.java:59) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.hash.TupleLoaderHashBase.<init>(TupleLoaderHashBase.java:29) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.hash.TupleLoaderHashMySQL.<init>(TupleLoaderHashMySQL.java:29) ~[jena-sdb-1.3.5.jar:1.3.5]
at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_45]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_45]
Caused by: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "CREATE TEMPORARY TABLE NNODETRIPLES
(N0 BIGINT ,
N1 LONGTEXT BINARY[*] CHARACTER SET UTF8 ,
N2 VARCHAR(10) BINARY CHARACTER SET UTF8 ,
N3 VARCHAR(200) BINARY CHARACTER SET UTF8 ,
N4 INT
) ENGINE=MYISAM "; erwartet "(, FOR, UNSIGNED, NOT, NULL, AS, DEFAULT, GENERATED, NOT, NULL, AUTO_INCREMENT, BIGSERIAL, SERIAL, IDENTITY, NULL_TO_DEFA
ULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ,, )"
Syntax error in SQL statement "CREATE TEMPORARY TABLE NNODETRIPLES
(N0 BIGINT ,
N1 LONGTEXT BINARY[*] CHARACTER SET UTF8 ,
N2 VARCHAR(10) BINARY CHARACTER SET UTF8 ,
N3 VARCHAR(200) BINARY CHARACTER SET UTF8 ,
N4 INT
) ENGINE=MYISAM "; expected "(, FOR, UNSIGNED, NOT, NULL, AS, DEFAULT, GENERATED, NOT, NULL, AUTO_INCREMENT, BIGSERIAL, SERIAL, IDENTITY, NULL_TO_DEFA
ULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TEMPORARY TABLE NNodeTriples
(n0 BIGINT ,
n1 LONGTEXT BINARY CHARACTER SET utf8 ,
n2 VARCHAR(10) BINARY CHARACTER SET utf8 ,
n3 VARCHAR(200) BINARY CHARACTER SET utf8 ,
n4 INT
) ENGINE=MYISAM [42001-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2.jar:1.3.172]
at org.h2.message.DbException.get(DbException.java:169) ~[h2.jar:1.3.172]
at org.h2.message.DbException.getSyntaxError(DbException.java:194) ~[h2.jar:1.3.172]
at org.h2.command.Parser.getSyntaxError(Parser.java:491) ~[h2.jar:1.3.172]
at org.h2.command.Parser.read(Parser.java:2822) ~[h2.jar:1.3.172]
at org.h2.command.Parser.readIfMore(Parser.java:809) ~[h2.jar:1.3.172]
[error] c.h.h.j.s.l.LoaderTuplesNodes - Error in thread: Problem making new tupleloader
com.hp.hpl.jena.sdb.SDBException: Problem making new tupleloader
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.updateOneTuple(LoaderTuplesNodes.java:292) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.access$200(LoaderTuplesNodes.java:43) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes$Commiter.run(LoaderTuplesNodes.java:362) ~[jena-sdb-1.3.5.jar:1.3.5]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_45]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_45]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.updateOneTuple(LoaderTuplesNodes.java:288) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.access$200(LoaderTuplesNodes.java:43) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes$Commiter.run(LoaderTuplesNodes.java:362) ~[jena-sdb-1.3.5.jar:1.3.5]
Caused by: com.hp.hpl.jena.sdb.SDBException: Problem initialising loader for [Triples]
at com.hp.hpl.jena.sdb.layout2.TupleLoaderBase.<init>(TupleLoaderBase.java:59) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.hash.TupleLoaderHashBase.<init>(TupleLoaderHashBase.java:29) ~[jena-sdb-1.3.5.jar:1.3.5]
at com.hp.hpl.jena.sdb.layout2.hash.TupleLoaderHashMySQL.<init>(TupleLoaderHashMySQL.java:29) ~[jena-sdb-1.3.5.jar:1.3.5]
at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_45]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_45]
Caused by: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "CREATE TEMPORARY TABLE NNODETRIPLES
(N0 BIGINT ,
N1 LONGTEXT BINARY[*] CHARACTER SET UTF8 ,
N2 VARCHAR(10) BINARY CHARACTER SET UTF8 ,
N3 VARCHAR(200) BINARY CHARACTER SET UTF8 ,
N4 INT
) ENGINE=MYISAM "; erwartet "(, FOR, UNSIGNED, NOT, NULL, AS, DEFAULT, GENERATED, NOT, NULL, AUTO_INCREMENT, BIGSERIAL, SERIAL, IDENTITY, NULL_TO_DEFA
ULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ,, )"
Syntax error in SQL statement "CREATE TEMPORARY TABLE NNODETRIPLES
(N0 BIGINT ,
N1 LONGTEXT BINARY[*] CHARACTER SET UTF8 ,
N2 VARCHAR(10) BINARY CHARACTER SET UTF8 ,
N3 VARCHAR(200) BINARY CHARACTER SET UTF8 ,
N4 INT
) ENGINE=MYISAM "; expected "(, FOR, UNSIGNED, NOT, NULL, AS, DEFAULT, GENERATED, NOT, NULL, AUTO_INCREMENT, BIGSERIAL, SERIAL, IDENTITY, NULL_TO_DEFA
ULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TEMPORARY TABLE NNodeTriples
(n0 BIGINT ,
n1 LONGTEXT BINARY CHARACTER SET utf8 ,
n2 VARCHAR(10) BINARY CHARACTER SET utf8 ,
n3 VARCHAR(200) BINARY CHARACTER SET utf8 ,
n4 INT
) ENGINE=MYISAM [42001-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2.jar:1.3.172]
at org.h2.message.DbException.get(DbException.java:169) ~[h2.jar:1.3.172]
at org.h2.message.DbException.getSyntaxError(DbException.java:194) ~[h2.jar:1.3.172]
at org.h2.command.Parser.getSyntaxError(Parser.java:491) ~[h2.jar:1.3.172]
at org.h2.command.Parser.read(Parser.java:2822) ~[h2.jar:1.3.172]
at org.h2.command.Parser.readIfMore(Parser.java:809) ~[h2.jar:1.3.172]
修改 必须更改此代码行:
StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash, DatabaseType.H2);
答案 0 :(得分:1)
H2不理解MySQL语法,例如ENGINE=MYISAM
。每种SQL语法都不同。您需要告诉SDB它正在使用H2数据库。