如果基数为 1:1,我需要从第一个表名创建 OWL 类,从第二个表名创建 OWL 类。如果基数为 1:* 并且其中一个表描述了对象属性,则从第一个表名创建 OWL 对象属性,而不是从第二个表名创建 OWL 类。如何从列名创建 OWL 类并完成其余工作?我在 Eclipse 中安装了 Protege OWL API。
package snippet;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import edu.stanford.smi.protege.exception.OntologyLoadException;
import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
public class Snippet {
public static void main(String[] args) throws OntologyLoadException {
//-Dprotege.dir=
// SQL Server DB with JDBC
String url = "jdbc:sqlserver://xxx:1433";
String userName = "xxx";
String password = "xxx";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection (url, userName, password);
Statement smt = con.createStatement();
smt.executeQuery("SELECT * from table_references");
ResultSet rs = smt.getResultSet();
while (rs.next()) {
String column1 = rs.getString("referenced_object_id");
String column2 = rs.getString("name");
String column3 = rs.getString("parent_column_id");
String column4 = rs.getString("referenced_column_id");
System.out.println(column1 + " | " + column2 + " | " + column3 + " | " + column4);
}
}
catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Protege API
}
}