import java.sql.*;
public class TESTA{
TESTA(){}
public static int product() {
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try{
String url = "jdbc:db2://192.168.2.3:50000/coffee:";
System.out.println("Before the Connection");
Connection con =
DriverManager.getConnection(url,"jence_user","jence_db");
DatabaseMetaData dbmd=con.getMetaData();
String[] types = {"TABLE"};
ResultSet rset=dbmd.getTables(null,"jence_user","%",types);
while(rset.next()){
System.out.println("Table Name
"+rset.getString("TABLE_NAME"));
}
return 0;
}catch(Exception e){
e.printStackTrace();
return -1; //it represent the error has occured
}
}
public static void main(String argv[]){
System.out.println("Output: "+TESTA.product());
}
}
When i was trying to get metadata of the database by the jdbc driver
that come with db2 database. Then i could not find any coulmn name.
Have any way to get table name form db2 database?
Bernd Hohmann - 20 Nov 2005 10:31 GMT
> When i was trying to get metadata of the database by the jdbc driver
> that come with db2 database. Then i could not find any coulmn name.
> Have any way to get table name form db2 database?
You can fetch the columns with the ResultSetMetaData from a SELECT *
dummy query on this table.
Bernd

Signature
"Ja, alles meine Herren" sprach Fürst Lichnowsky. "Ooch det roochen?"
"Ja, auch das Rauchen." "Ooch im Tiergarten?" "Ja, auch im Tiergarten
darf geraucht werden, meine Herren." Und so endeten die Barrikadenkämpfe
des 18. März in Berlin
Maroon - 20 Nov 2005 11:34 GMT
Hello
I have found my solution. The schema name is case sensitive. I used
lower case, but it will be upper case.
Thanks