Hi everyone,

I have done some hacks that allow a limited generate mappings over an 
ODBC connection.

These are in
de.fuberlin.wiwiss.d2rq.dbschema.DatabaseSchemaInspector

public List foreignKeys(RelationName tableName, int direction) {
....
         } catch (SQLException ex) {
                        return new ArrayList();
          }

     public List primaryKeyColumns(RelationName tableName) {
....
         } catch (SQLException ex) {
                        return new ArrayList();
          }

.....

    public ColumnType columnType(Attribute column) {
         if (this.cachedColumnTypes.containsKey(column)) {
             return (ColumnType) this.cachedColumnTypes.get(column);
         }
         try {
             ResultSet rs = this.schema.getColumns(null, 
column.schemaName(), column.tableName(), column.attributeName());
             if (rs.next()) {
                 ColumnType type = new 
ColumnType(rs.getInt("DATA_TYPE"), rs.getString("TYPE_NAME"));
                 rs.close();
                 this.cachedColumnTypes.put(column, type);
                 return type;
             } else {
                 rs = this.schema.getColumns(null, null, 
column.tableName(), null);
                 while (rs.next()) {
                     String columnName = rs.getString("COLUMN_NAME");
                     if (columnName.equals(column.attributeName())){
                         ColumnType type = new 
ColumnType(rs.getInt("DATA_TYPE"), rs.getString("TYPE_NAME"));
                         rs.close();
                         this.cachedColumnTypes.put(column, type);
                         return type;
                     }
                 }
                 throw new D2RQException("Column " + column + " not 
found in database");
             }
     } catch (SQLException ex) {
             throw new D2RQException("Database exception", ex);
     }
     }

The generated mapping is missing links and stuff that the direct JDBC 
option offers but is better than nothing.
You also have to fill the primarky keys in by hand or run code to quess 
the primary key. (I will post another email about that)

-- 
Dr Christian Brenninkmeijer
Department of Computer Science
University of Manchester


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
d2rq-map-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel

Reply via email to