2013-05-22 75 views
-1

我需要從第一個表名稱,如果基數1:1和第二個表名稱中的OWL類創建OWL類。如果基數1:*和其中一個表描述對象屬性,則從第一個表名創建OWL對象屬性,而不是從第二個表名創建OWL類。首先,我如何從列名創建類?我在Eclipse中安裝了OWL API。迭代Sql.result集

公共類片段{

public static void main(String[] args) { 


    // SQL Server DB with JDBC 
    String url = "jdbc:sqlserver://isd.ktu.lt:1433"; 
    String databaseName= "xxxx"; 
    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 

} 

}

回答

0

你可以使用 而(rs.next()){ rs.getString( 「列名」); }