这是我的代码
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import com.hp.hpl.jena.db.DBConnection;
import com.hp.hpl.jena.db.IDBConnection;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ModelMaker;
public class myontoly {
public static final String MYSQL_DB_CLASSNAME = "com.mysql.jdbc.Driver";
public static final String MYSQL_DB_URL =
"jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=UTF8";
public static final String MYSQL_DB_USER = "root";
public static final String MYSQL_DB_PASSWD = "mysql2011510";
public static final String DB = "MySQL";
public static void main(String[] args) {
// loading the JDBC driver
try {
Class.forName(MYSQL_DB_CLASSNAME).newInstance();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Create database connection
IDBConnection conn = new DBConnection(MYSQL_DB_URL, MYSQL_DB_USER, MYSQL_DB_PASSWD, DB);
//Use the connection to create a model maker
ModelMaker maker = ModelFactory.createModelRDBMaker(conn);
Model base = maker.createDefaultModel();
FileInputStream inputStreamfile = null;
File file = new File("file:./Taxonomy.owl");
try {
inputStreamfile = new FileInputStream(file);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
InputStreamReader in = null;
try {
in =new InputStreamReader(inputStreamfile, "UTF-8");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
base.read(in, null);
try {
in.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
base.commit();
//Close the database connection
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
错误信息,我在线程“main”java.lang.NoSuchMethodError中尝试了jena 2.4、2.6.4异常:com.hp.hpl.jena.rdf.model.ModelFactory.createModelRDBMaker(Lcom/hp/hpl/jena/ db/IDBConnection;)Lcom/hp/hpl/jena/rdf/model/ModelMaker; 在 com.webservicecom.mysql.myontoly.main(myontoly.java:71))