*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ---------------
* TestDBMetaData.java
* ---------------
* Author: Volker Berlin
*
*/
package smallsql.junit;
import java.sql.*;
public class TestDBMetaData extends BasicTestCase {
public TestDBMetaData(){
super();
}
public TestDBMetaData(String arg0) {
super(arg0);
}
public void testCatalogs() throws Exception{
Connection con = AllTests.getConnection();
try{
con.createStatement().execute("drop database test2\n\r\t");
}catch(SQLException e){
}
con.createStatement().execute("create database test2");
DatabaseMetaData md = con.getMetaData();
ResultSet rs = md.getCatalogs();
while(rs.next()){
System.out.println( "testCatalogs:"+rs.getObject(1) );
}
}
public void testTableColumn() throws Exception{
Connection con = AllTests.getConnection();
dropTable(con,"tableColumns");
dropView( con, "viewColumns");
con.createStatement().execute("create table tableColumns(a int default 5)");
DatabaseMetaData md = con.getMetaData();
ResultSet rs = md.getColumns(null, null, "tableColumns", null);
assertTrue( "No row", rs.next() );
assertEquals( "a", rs.getObject("COLUMN_NAME") );
assertEquals( "INT", rs.getObject("TYPE_NAME") );
assertEquals( "5", rs.getObject("COLUMN_Def") );
con.createStatement().execute("create view viewColumns as Select * from tableColumns");
rs = md.getColumns(null, null, "viewColumns", null);
assertTrue( "No row", rs.next() );
assertEquals( "a", rs.getObject("COLUMN_NAME") );
assertEquals( "INT", rs.getObject("TYPE_NAME") );
assertEquals( "5", rs.getObject("COLUMN_Def") );
dropView( con, "viewColumns");
dropTable( con, "tableColumns");
}
}