You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by NLA Systems Ltd <nl...@keyworld.net> on 2006/10/11 15:59:15 UTC
MetaData problem
Hello all
This is my first post to this list.
I am connecting to a Derby database in embedded mode among other databases.
I have the code below to get all the columns of a table. This code works
fine with all my other databases but not with Derby. It seems that the
getColumns() method is returning an empty resultset. I hope someone can
give me a hint on why this is happening. Thanks a lot!
DatabaseMetaData dbmd=dbConn.dbConnection.getMetaData();
ResultSet rs=dbmd.getColumns(null,null,"myTable", null);
while (rs.next()) {
.......
}
}
I am using release 10.1.2.0
Regards
Noel
Re: MetaData problem
Posted by Myrna van Lunteren <m....@gmail.com>.
On 10/11/06, NLA Systems Ltd <nl...@keyworld.net> wrote:
> Hello all
>
> This is my first post to this list.
>
> I am connecting to a Derby database in embedded mode among other databases.
> I have the code below to get all the columns of a table. This code works
> fine with all my other databases but not with Derby. It seems that the
> getColumns() method is returning an empty resultset. I hope someone can
> give me a hint on why this is happening. Thanks a lot!
>
>
>
> DatabaseMetaData dbmd=dbConn.dbConnection.getMetaData();
> ResultSet rs=dbmd.getColumns(null,null,"myTable", null);
>
> while (rs.next()) {
> .......
> }
> }
>
> I am using release 10.1.2.0
>
> Regards
> Noel
>
Hi Noel,
There's not much information as you didn't provide the create table
statement, nor indicated whether derby.log had any useful details, but
at a guess, I would think it can't find your table...Or maybe there
are two tables and the rows went into one & you're retrieving from the
other.
I suggest you to check the following things:
- was the table created within a specific schema?
If when you created the table, you started your Derby process
with a specific login/user, then it's likely the table was created
under that user, i.e. the table is really 'firstuser.myTable'.
To access a table like this, you can either fully qualify the
name, login with the same user, or first do an explicit 'set schema
firstuser'.
- confirm that the table was created in the mixed case you specify.
By default, Derby will uppercase the table (and column,etc...)
identifiers. If you do not want this, you should double quote the
table name at creation time.
To see what is really happening, you can look in the derby.log file;
it should have been created automatically in the same location as the
database. To get more information in it, create a derby.properties
file in the directory where you start derby (or where the database got
created), and add the following:
derby.infolog.append=true
derby.language.logStatementText=true
derby.stream.error.logSeverityLevel=0
To see how your tables got created, open an ij session, connect to
your database, and select * from sys.systables.
HTH
Myrna
Re: MetaData problem
Posted by NLA Systems Ltd <nl...@keyworld.net>.
Rajesh Thanks!
That was it!
Noel
Rajesh Kartha wrote:
> By default in Derby, the table names are stored internally in CAPS.
> Hence you should use:
>
> ResultSet rs=dbmd.getColumns(null,null,"MYTABLE", null);
>
> However if the tablename is created in a case-sensitive manner like:
>
> create table "myTable"(i int, j char(1), k char(2), l char(3));
>
> then
>
> dbmd.getColumns(null,null,"myTable", null);
> should work.
>
> HTH,
> -Rajesh
>
>
> NLA Systems Ltd wrote:
>
>> Hello all
>>
>> This is my first post to this list.
>>
>> I am connecting to a Derby database in embedded mode among other
>> databases.
>> I have the code below to get all the columns of a table. This code
>> works fine with all my other databases but not with Derby. It seems
>> that the getColumns() method is returning an empty resultset. I hope
>> someone can give me a hint on why this is happening. Thanks a lot!
>>
>>
>>
>> DatabaseMetaData dbmd=dbConn.dbConnection.getMetaData();
>> ResultSet rs=dbmd.getColumns(null,null,"myTable", null);
>>
>> while (rs.next()) {
>> ....... }
>> }
>>
>> I am using release 10.1.2.0
>>
>> Regards
>> Noel
>>
>
>
--
*NLA **Systems Ltd*
http://www.nlasystems.com
Re: MetaData problem
Posted by Rajesh Kartha <ka...@gmail.com>.
By default in Derby, the table names are stored internally in CAPS.
Hence you should use:
ResultSet rs=dbmd.getColumns(null,null,"MYTABLE", null);
However if the tablename is created in a case-sensitive manner like:
create table "myTable"(i int, j char(1), k char(2), l char(3));
then
dbmd.getColumns(null,null,"myTable", null);
should work.
HTH,
-Rajesh
NLA Systems Ltd wrote:
> Hello all
>
> This is my first post to this list.
>
> I am connecting to a Derby database in embedded mode among other
> databases.
> I have the code below to get all the columns of a table. This code
> works fine with all my other databases but not with Derby. It seems
> that the getColumns() method is returning an empty resultset. I hope
> someone can give me a hint on why this is happening. Thanks a lot!
>
>
>
> DatabaseMetaData dbmd=dbConn.dbConnection.getMetaData();
> ResultSet rs=dbmd.getColumns(null,null,"myTable", null);
>
> while (rs.next()) {
> .......
> }
> }
>
> I am using release 10.1.2.0
>
> Regards
> Noel
>