You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Brandon Harper <b....@gmail.com> on 2006/04/28 18:57:49 UTC

Abator Introspection Problem When Calling getPrimaryKeys() In JDBC Driver

Foreward: I'm new to the list and I mostly just have academic
experience with Java though I've been programming for many years, so
please be gentle.

I'm currently using Abator to introspect a datasource on a fairly
esoteric "database" platfrom called Omnidex.  Omnidex is not really a
database though it does use fairly standard SQL, it's more like a
specialized full-text indexing engine for flat-files.  While it does
have a JDBC driver of which the interface appears to be JDBC
compliant, the underlying methods are pretty poorly implemented.  As
such, some of the methods in the driver to retrieve database meta
information look like this:

public ResultSet getPrimaryKeys(String s, String s1, String s2)
       throws SQLException
   {
       throw new OdxCLJException(25500);
   }


When using Abator to introspect an Omnidex datasource, it obviously
calls the getPrimaryKeys() method for which it ends up throwing an
exception:

java -jar abator.jar abator-hunters.xml true

omnidex.client.OdxCLJException: The message 25500 was not found in the
Omnidex e rror message files.
       at omnidex.jdbc.OdxJDBCDatabaseMetaData.getPrimaryKeys(OdxJDBCDatabaseMe
taData.java:1845)
       at org.apache.ibatis.abator.internal.db.DatabaseIntrospector.generateCol
umnDefinitions(DatabaseIntrospector.java:162)
       at org.apache.ibatis.abator.config.AbatorContext.generateFiles(AbatorCon
text.java:211)
       at org.apache.ibatis.abator.api.Abator.generate(Abator.java:148)
       at org.apache.ibatis.abator.api.AbatorRunner.main(AbatorRunner.java:64)


Believe it or not primary keys are really not important with this
particular engine since it's mostly used to search fully indexed text
files.  That said, for the most part I'll be using iBatis to do string
searches on various fields rather than worrying about relationships,
keys, etc.

Looking at the Abator sourcecode, it looks like the part of the code
in DatabaseIntrospecter.java at lines 162-165 could be wrapped in a
try/catch block to catch an exception coming back from the JDBC driver
when it calls the getPrimaryKeys() method?  I'm sure I could submit a
patch for this myself, but I thought it would be a very easy fix for
an existing developer with commit access to the project?  I've also
submitted a bug report to the database vendor for this issue, but I
have the feeling it will not be fixed soon if ever...

Thanks,

- Brandon

--
http://devnulled.com

Re: Abator Introspection Problem When Calling getPrimaryKeys() In JDBC Driver

Posted by Jeff Butler <je...@gmail.com>.
It MUST extend SQLException - otherwise it would break the JDBC contract.

I'm glad this will work for you - I'll make the change in Abator.

Jeff Butler


On 4/28/06, Brandon Harper <b....@gmail.com> wrote:
>
> On 4/28/06, Jeff Butler <je...@gmail.com> wrote:
> >
> > Would that still meet your requirements?  If so, then I think this would
> be
> > OK - I could issue a warning, and continue.
> >
>
> Yep, that would work great actually.  This particular DB platform is
> basically read-only, so I wouldn't be using any of the insert or
> update methods anyway.
>
> One of many other things about that driver which is not good; after
> taking a look at the exception which is thown from that driver, said
> exception extends SQLException.  :(
>
> I just built Abator from source and added a try/catch block for
> SQLException and it seems to be working fine now as far as I can tell.
>
> Thanks,
>
> - Brandon
>
> --
> http://devnulled.com
>

Re: Abator Introspection Problem When Calling getPrimaryKeys() In JDBC Driver

Posted by Brandon Harper <b....@gmail.com>.
On 4/28/06, Jeff Butler <je...@gmail.com> wrote:
>
> Would that still meet your requirements?  If so, then I think this would be
> OK - I could issue a warning, and continue.
>

Yep, that would work great actually.  This particular DB platform is
basically read-only, so I wouldn't be using any of the insert or
update methods anyway.

One of many other things about that driver which is not good; after
taking a look at the exception which is thown from that driver, said
exception extends SQLException.  :(

I just built Abator from source and added a try/catch block for
SQLException and it seems to be working fine now as far as I can tell.

Thanks,

- Brandon

--
http://devnulled.com

Re: Abator Introspection Problem When Calling getPrimaryKeys() In JDBC Driver

Posted by Jeff Butler <je...@gmail.com>.
This would ask Abator to pretend that there was not really a primary key.
If Abator pretended that there was not a primary key, then the only
generated methods would be:

insert
deleteByExample
selectByExample

Would that still meet your requirements?  If so, then I think this would be
OK - I could issue a warning, and continue.

Jeff Butler

On 4/28/06, Brandon Harper <b....@gmail.com> wrote:
>
> Foreward: I'm new to the list and I mostly just have academic
> experience with Java though I've been programming for many years, so
> please be gentle.
>
> I'm currently using Abator to introspect a datasource on a fairly
> esoteric "database" platfrom called Omnidex.  Omnidex is not really a
> database though it does use fairly standard SQL, it's more like a
> specialized full-text indexing engine for flat-files.  While it does
> have a JDBC driver of which the interface appears to be JDBC
> compliant, the underlying methods are pretty poorly implemented.  As
> such, some of the methods in the driver to retrieve database meta
> information look like this:
>
> public ResultSet getPrimaryKeys(String s, String s1, String s2)
>       throws SQLException
>   {
>       throw new OdxCLJException(25500);
>   }
>
>
> When using Abator to introspect an Omnidex datasource, it obviously
> calls the getPrimaryKeys() method for which it ends up throwing an
> exception:
>
> java -jar abator.jar abator-hunters.xml true
>
> omnidex.client.OdxCLJException: The message 25500 was not found in the
> Omnidex e rror message files.
>       at omnidex.jdbc.OdxJDBCDatabaseMetaData.getPrimaryKeys
> (OdxJDBCDatabaseMe
> taData.java:1845)
>       at
> org.apache.ibatis.abator.internal.db.DatabaseIntrospector.generateCol
> umnDefinitions(DatabaseIntrospector.java:162)
>       at org.apache.ibatis.abator.config.AbatorContext.generateFiles
> (AbatorCon
> text.java:211)
>       at org.apache.ibatis.abator.api.Abator.generate(Abator.java:148)
>       at org.apache.ibatis.abator.api.AbatorRunner.main(AbatorRunner.java
> :64)
>
>
> Believe it or not primary keys are really not important with this
> particular engine since it's mostly used to search fully indexed text
> files.  That said, for the most part I'll be using iBatis to do string
> searches on various fields rather than worrying about relationships,
> keys, etc.
>
> Looking at the Abator sourcecode, it looks like the part of the code
> in DatabaseIntrospecter.java at lines 162-165 could be wrapped in a
> try/catch block to catch an exception coming back from the JDBC driver
> when it calls the getPrimaryKeys() method?  I'm sure I could submit a
> patch for this myself, but I thought it would be a very easy fix for
> an existing developer with commit access to the project?  I've also
> submitted a bug report to the database vendor for this issue, but I
> have the feeling it will not be fixed soon if ever...
>
> Thanks,
>
> - Brandon
>
> --
> http://devnulled.com
>