Re: How to know columns names in Derby database table
- From: Dyreatnews@xxxxxxx
- Date: Mon, 24 Sep 2007 12:04:54 +0200
"Luis Angel Fdez. Fdez." <laffdez@xxxxxxxxx> writes:
Hi!
I'm trying this:
[...]
Vector<String> vNames = new Vector<String>();
String[] names;
try {
ResultSet myRs;
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
con = DriverManager.getConnection("jdbc:derby:/home/koxo/tmp/db/tests/
ubicharge");
myRs = con.getMetaData().getColumns(null, null, "bornes", "%");
while (myRs.next()) {
String str = myRs.getString("COLUMN_NAME");
vNames.add(str);
}
} catch (SQLException sqle) {
System.out.println(sqle.toString());
}
catch(Exception e) {
System.out.println("getColumnNames: "+e.toString());
e.printStackTrace();
}
[...]
The connection is made, and the 'bornes' table exists, but the loop is
never executed. What's wrong?
Derby stores table names as upper case, even if you create the table
with lower case. That is,
create table bornes(...);
is equivalent to
CREATE TABLE BORNES(...);
If you read the javadoc for DatabaseMetaData.getColumns() carefully you'll
see that the third argument, the table name pattern, "must match the
table name as it is stored in the database". Hence you must use upper
case in the metadata call, i.e.
con.getMetaData().getColumns(null, null, "BORNES", "%");
should work.
PS: For derby-specific questions it is usually better to ask on the
derby-user mailing list.
HTH
--
dt
.
- References:
- How to know columns names in Derby database table
- From: Luis Angel Fdez. Fdez.
- How to know columns names in Derby database table
- Prev by Date: Re: CLOB issue with JDBC, IBATIS and Oracle 10g
- Next by Date: Re: CLOB issue with JDBC, IBATIS and Oracle 10g
- Previous by thread: Re: [SOLVED] Re: How to know columns names in Derby database table
- Index(es):
Relevant Pages
|
|