db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ян Программист <webautoma...@gmail.com>
Subject Re: JDBC Metadata cursor
Date Thu, 15 Apr 2010 09:08:19 GMT
Here is the output of your example class "z":

Next column is called TABLEID
Next column is called TABLENAME
Next column is called TABLETYPE
Next column is called SCHEMAID
Next column is called LOCKGRANULARITY

Interesting, but my code started to work:

@Test
public final void testGetColumns() throws SQLException {
java.sql.ResultSet column_set = metadata.getColumns(null, "SYS",
"SYSTABLES", "%");
//column_set.relative(2);
//For scrollable result set:
//column_set.absolute(1);
//assertTrue(column_set.first());
//column_set.beforeFirst();
//assertTrue(column_set.next());
//assertTrue(column_set.isFirst());
//For updatable result set:
//column_set.moveToCurrentRow();
//assertTrue(column_set.next());
//int i=0;
//while ( column_set.next() )
//{
assertTrue(column_set.next());
String column_name = column_set.getString(3);
assertNotNull(column_name);
assertTrue(column_name.length()>0);
System.out.println(column_name);
//}
//assertNotNull(column_name);
//assertTrue(column_name.length()>0);

}

JUnit test reporter indicates this test passed("green" state).
System.out.prinln() pushed following into output stream:

SYSTABLES

The same is for while() loop.

Thanks help. The courious thing is that I remember exactly that in one of my
previous tryouts there where only next(), but an exception about undefined
cursor state fired. Hm,..
By the way - metadata connection was properly defined in setUp().

P.S. In normal unit tests it is a bad idea to write into System.out
stream. Normally it should be written into logger (Log4j). Otherwise, in
some cases, benchmarks would not be usable; if data writing operation would
take much more time than assertions. John

Mime
View raw message