-- 作者:xiweiwang
-- 发布时间:12/5/2010 5:10:00 PM
-- 急,大家帮忙看看吧
package myontology; import java.io.*; import java.sql.SQLException; import com.hp.hpl.jena.db.*; import com.hp.hpl.jena.rdf.model.*; class Ontology{ public static final String strDriver ="com.sql.jdbc.Driver"; // path of driver class public static final String strURL ="jdbc:sql://localhost/ontology"; // URL of database public static final String strUser ="root"; // database user id public static final String strPassWord ="sql"; // database password public static final String strDB="SQL"; // 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("ClassNotFoundException, Driver is not available..."); } // 使用数据库连接参数创建一个模型制造器 ModelMaker maker = ModelFactory.createModelRDBMaker(conn); // 创建一个默认模型,命名为 MyOntology Model defModel = maker.createModel("MyOntology"); // 准备需要存入数据库的本体文件,建立输入文件流 FileInputStream inputStreamfile = null; try { File file = new File("C:\camera.owl"); inputStreamfile = new FileInputStream(file); } catch (FileNotFoundException e) { e.printStackTrace(); System.out.println("Ontology File is not available..."); } InputStreamReader in = null; try { in = new InputStreamReader(inputStreamfile, "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){ e.printStackTrace(System.out); System.out.println("Exceptions occur..."); } } } 麻烦高手帮忙看看,我这样写代码后,我生成的数据库文件保存到哪里了,我怎么在sql 中找不到啊
|