Hi Christian,

This is cool stuff!

Can you explain a bit about what's going on? Why does it fail on ODBC without 
these changes?

What's the exception that would be thrown on the foreignKeys() and 
primaryKeyColumns() methods?

Why does the getColumns(null, schema, table, column) call fail for ODBC?

Where you have this.schema.getColumns(null, null, column.tableName(), null), 
would it still work if you used column.schemaName() instead of null? I assume 
that the schema name would be null anyways ...

I'm asking because I'd like to figure out whether these changes can be 
incorporated without causing issues when other JDBC drivers are used.

Best,
Richard


On 12 Jan 2011, at 16:43, Christian Brenninkmeijer wrote:

> 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


------------------------------------------------------------------------------
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