以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  求高手解答,myeclipse连接mysql存入本体运行程序后警告Table 'jena.jena_sys_stmt' doesn't exist?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=124022)


--  作者:beinchangg
--  发布时间:5/3/2012 4:24:00 PM

--  求高手解答,myeclipse连接mysql存入本体运行程序后警告Table 'jena.jena_sys_stmt' doesn't exist?


--  作者:wcz901208
--  发布时间:3/9/2013 11:06:00 AM

--  
同上,上面是我的代码,应该来说基本上是从网上抄来的

/** 将本体存入MySQL **/

import java.io.*;

import java.sql.SQLException;

import com.hp.hpl.jena.db.*;

import com.hp.hpl.jena.rdf.model.*;

public class Onto2Database{

     

     public static final String strDriver = "com.mysql.jdbc.Driver"; //path of driver class

     public static final String strURL = "jdbc:mysql://localhost/OntoDB"; // URL of database

     public static final String strUser = "root"; //database user id

     public static final String strPassWord = ""; //database password

     public static final String strDB =  "MySQL"; //database type

     public static void main(String[] args){

         try{

            // 创建一个数据库连接

              IDBConnection conn = new DBConnection ( strURL, strUser, strPassWord, strDB );

            

              // 加载数据库驱动类,需要处理异常

              try{

                   Class.forName(strDriver);

              }catch(ClassNotFoundException e) {

                   System.out.println("Driver is not available...");

              }

              

            // 使用数据库连接参数创建一个模型制造器

              ModelMaker maker = ModelFactory.createModelRDBMaker(conn);

              

              // 创建一个默认模型,命名为 MyOntology

              Model defModel = maker.createModel("MyOntology");

              // 准备需要存入数据库的本体文件,建立输入文件流

              FileInputStream inputSreamfile = null;

              try {

                   File file = new File("D:\\ZhangAndZhao_EKB.owl");

                   inputSreamfile = new FileInputStream(file);

              } catch (FileNotFoundException e) {

                   e.printStackTrace();

                   System.out.println("Ontology File is not available...");

              }

              

              InputStreamReader in = null;

              try {

                   in = new InputStreamReader(inputSreamfile,"UTF-8");

              } catch (UnsupportedEncodingException e) {

                   e.printStackTrace();

              }

              

            // 读取文件

            defModel.read(in,null);

            

            // 关闭输入流读取器

            try {

                   in.close();

              } catch (IOException e) {

                   e.printStackTrace();

              }

            

              // 执行数据转换,将本体数据存入数据库

            defModel.commit();

              

            // 关闭数据库连接

              try {

                   conn.close();

              } catch (SQLException e) {

                   e.printStackTrace();

              }

         }catch(RDFRDBException e){

              System.out.println("Exceptions occur...");

         }

     }

} // 代码结束

下面是错误信息


WARN [main] (DriverRDB.java:430) - Problem formatting database
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ontodb.jena_sys_stmt' doesn't exist
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
 at com.mysql.jdbc.Util.getInstance(Util.java:386)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2618)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
 at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:842)
 at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681)
 at com.hp.hpl.jena.db.impl.SQLCache.runSQLGroup(SQLCache.java:560)
 at com.hp.hpl.jena.db.impl.DriverRDB.formatAndConstructSystemSpecializedGraph(DriverRDB.java:427)
 at com.hp.hpl.jena.db.impl.DriverRDB.getSystemSpecializedGraph(DriverRDB.java:305)
 at com.hp.hpl.jena.db.impl.DriverRDB.getDefaultModelProperties(DriverRDB.java:835)
 at com.hp.hpl.jena.db.DBConnection.getDefaultModelProperties(DBConnection.java:195)
 at com.hp.hpl.jena.db.impl.GraphRDBMaker.consGraph(GraphRDBMaker.java:123)
 at com.hp.hpl.jena.db.impl.GraphRDBMaker.createGraph(GraphRDBMaker.java:107)
 at com.hp.hpl.jena.rdf.model.impl.ModelMakerImpl.createModel(ModelMakerImpl.java:46)
 at com.hp.hpl.jena.rdf.model.impl.ModelMakerImpl.createModel(ModelMakerImpl.java:49)
 at Onto2Database.main(Onto2Database.java:63)
Exception in thread "main" com.hp.hpl.jena.db.RDFRDBException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ontodb.jena_sys_stmt' doesn't exist
 at com.hp.hpl.jena.db.impl.DriverRDB.formatAndConstructSystemSpecializedGraph(DriverRDB.java:477)
 at com.hp.hpl.jena.db.impl.DriverRDB.getSystemSpecializedGraph(DriverRDB.java:305)
 at com.hp.hpl.jena.db.impl.DriverRDB.getDefaultModelProperties(DriverRDB.java:835)
 at com.hp.hpl.jena.db.DBConnection.getDefaultModelProperties(DBConnection.java:195)
 at com.hp.hpl.jena.db.impl.GraphRDBMaker.consGraph(GraphRDBMaker.java:123)
 at com.hp.hpl.jena.db.impl.GraphRDBMaker.createGraph(GraphRDBMaker.java:107)
 at com.hp.hpl.jena.rdf.model.impl.ModelMakerImpl.createModel(ModelMakerImpl.java:46)
 at com.hp.hpl.jena.rdf.model.impl.ModelMakerImpl.createModel(ModelMakerImpl.java:49)
 at Onto2Database.main(Onto2Database.java:63)
com.hp.hpl.jena.shared.JenaException: The database appears to be unformatted or corrupted and
an attempt to automatically format the database has failed

 at com.hp.hpl.jena.db.impl.DriverRDB.getSystemSpecializedGraph(DriverRDB.java:311)
 at com.hp.hpl.jena.db.impl.DriverRDB.getDefaultModelProperties(DriverRDB.java:835)
 at com.hp.hpl.jena.db.DBConnection.getDefaultModelProperties(DBConnection.java:195)
 at com.hp.hpl.jena.db.impl.GraphRDBMaker.consGraph(GraphRDBMaker.java:123)
 at com.hp.hpl.jena.db.impl.GraphRDBMaker.createGraph(GraphRDBMaker.java:107)
 at com.hp.hpl.jena.rdf.model.impl.ModelMakerImpl.createModel(ModelMakerImpl.java:46)
 at com.hp.hpl.jena.rdf.model.impl.ModelMakerImpl.createModel(ModelMakerImpl.java:49)
 at Onto2Database.main(Onto2Database.java:63)
Caused by: com.hp.hpl.jena.db.RDFRDBException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ontodb.jena_sys_stmt' doesn't exist
 at com.hp.hpl.jena.db.impl.DriverRDB.formatAndConstructSystemSpecializedGraph(DriverRDB.java:477)
 at com.hp.hpl.jena.db.impl.DriverRDB.getSystemSpecializedGraph(DriverRDB.java:305)
 ... 7 more


求教啊


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.988ms