4 * Created on June 23, 2003, 3:19 PM
11 package qa
.drivers
.hsqldb
;
13 import com
.sun
.star
.uno
.UnoRuntime
;
14 import complexlib
.ComplexTestCase
;
15 import java
.lang
.reflect
.Method
;
16 import qa
.drivers
.hsqldb
.DriverTest
;
19 public class DatabaseMetaData
{
21 private java
.sql
.DatabaseMetaData m_xMD
;
22 private DriverTest m_TestCase
;
24 /** Creates a new instance of DatabaseMetaData */
25 public DatabaseMetaData(DriverTest _testCase
,java
.sql
.DatabaseMetaData _xmd
) {
26 m_TestCase
= _testCase
;
30 protected void assure(String _sText
,boolean btest
){
31 m_TestCase
.assurePublic(_sText
,btest
);
34 protected void testMethod(String sName
,Class
[] params
,Object
[] objParams
,int nCount
){
36 System
.out
.println("test method " + sName
);
38 Method aGet
= ((Object
)m_xMD
).getClass().getDeclaredMethod(sName
, params
);
40 ResultSet rs
= (ResultSet
)aGet
.invoke(m_xMD
, objParams
);
41 ResultSetMetaData rsMD
= rs
.getMetaData();
43 assure( sName
+ " returns wrong column count" , rsMD
.getColumnCount() == nCount
);
46 assure( sName
+ " returns wrong column count" , false);
47 } catch( java
.lang
.NoSuchMethodException ex
) {
48 assure("Method " + sName
+ " could not be found!",false);
49 } catch( java
.lang
.IllegalAccessException ex
) {
50 assure("IllegalAccessException!",false);
51 } catch( SQLException ex
) {
52 assure("SQLException occured: " + ex
.getMessage() ,false);
53 } catch( java
.lang
.reflect
.InvocationTargetException ex
) {
54 assure("IllegalAccessException!",false);
65 ResultSet rs
= m_xMD
.getTables(null,null,"TESTCASE",null);
68 String catalog
= rs
.getString( 1 );
72 String schema
= rs
.getString( 2 );
76 String table
= rs
.getString( 3 );
77 String type
= rs
.getString( 4 );
78 System
.out
.println("Catalog: " + catalog
+ " Schema: " + schema
+ " Table: " + table
+ " Type: " + type
);
79 System
.out
.println("------------------ Columns ------------------");
80 ResultSet rsColumns
= m_xMD
.getColumns(catalog
,schema
,table
,"%");
81 while ( rsColumns
.next() )
83 System
.out
.println("Column: " + rsColumns
.getString( 4 ) + " Type: " + rsColumns
.getInt( 5 ) + " TypeName: " + rsColumns
.getString( 6 ) );
90 //testMethod("getTypeInfo", zclass,empty,17);
92 Class[] zclass = new Class[]{};
93 Object[] empty = new Object[]{};
94 testMethod("getCatalogs", zclass,empty,1);
96 testMethod("getSchemas", zclass,empty,2);
97 testMethod("getTableTypes", zclass,empty,1);
98 Class[] a4 = new Class[4];
99 Object[] o4 = new Object[4];
100 a4[0] = Class.forName("java.lang.Object");
101 a4[1] = Class.forName("java.lang.String");
102 a4[2] = Class.forName("java.lang.String");
103 a4[3] = Class.forName("java.lang.String");
109 testMethod("getColumnPrivileges", a4,o4,7);
110 testMethod("getColumns", a4,o4,18);
111 testMethod("getProcedureColumns", a4,o4,13);
112 testMethod("getColumns", a4,o4,18);
114 Class[] a3 = new Class[3];
115 Object[] o3 = new Object[3];
116 a3[0] = Class.forName("java.lang.Object");
117 a3[1] = Class.forName("java.lang.String");
118 a3[2] = Class.forName("java.lang.String");
124 testMethod("getExportedKeys", a3,o3,14);
125 testMethod("getImportedKeys", a3,o3,14);
126 testMethod("getPrimaryKeys", a3,o3,14);
127 testMethod("getProcedures", a3,o3,5);
128 testMethod("getTablePrivileges", a3,o3,6);
129 testMethod("getVersionColumns", a3,o3,7);
130 // testMethod("getCrossReference", a3,o3,14);
132 } catch( java.lang.ClassNotFoundException ex) {
133 assure("ClassNotFoundException: " + ex.getMessage() ,false);
138 public com.sun.star.sdbc.XResultSet getCrossReference(Object obj, String str, String str2, Object obj3, String str4, String str5) {
140 public com.sun.star.sdbc.XResultSet getIndexInfo(Object obj, String str, String str2, boolean param, boolean param4) {
143 public com.sun.star.sdbc.XResultSet getTables(Object obj, String str, String str2, String[] str3) {
146 public com.sun.star.sdbc.XResultSet getUDTs(Object obj, String str, String str2, int[] values) {
149 public com.sun.star.sdbc.XResultSet getBestRowIdentifier(Object obj, String str, String str2, int param, boolean param4) throws com.sun.star.sdbc.SQLException {