Subject Re: [Firebird-Java] Using FBDatabaseMetadata
Author Todd Jonker
On 5/6/02 5:07 AM, luca.lafranchi@... wrote:

> I was trying to run this code:
>
> DatabaseMetaData dmd = connection.getMetaData();
>
> ResultSet rset = dmd.getTables(null,null,null,null); //This should
> return all tables in the database...
>
> I get a NullPointerException in dmd.getTables(...) beacause the
> pattern parameter is null, and the method
> FBDatabaseMetaData.hasNoWildcards(String pattern) doesn't check if
> pattern is null. If I write "%" instead of null everything works fine...
>
> I don't exactly know what the specs say, but I'd think that if pattern
> is null, than it should be treated as "%"...
>
> What do you think?

I encountered the same problem last weekend. The JDBC API documentation
does not explicitly state whether or not the tableNamePattern parameter may
be null, though it *does* state that the other three parameters may be null.

http://java.sun.com/j2se/1.3/docs/api/java/sql/DatabaseMetaData.html

My reading of the spec, then, is that all-null call Luca describes above
should be supported. Should be an easy fix.

(On the same note, its also unclear how "" should be treated. Sun has
always been woefully lax about documenting parameter ranges, especially
where null and empty-String are concerned. If "" is not valid, the driver
would hopefully throw IllegalArgumentException instead of NPE.)


.T.

PS: I'm new to Firebird since last week... And loving every minute! Bye-bye
PostgreSQL! :-)


--

This would've been incredibly useful to people designing vacuum tubes.
-- Theodore Gray, Co-founder Wolfram Research, demonstrating Mathematica
on MacOS X