469,312 Members | 2,496 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

JDBC: DatabaseMetaData



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","jenc e_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?

Nov 20 '05 #1
2 3036
Maroon wrote:
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

--
"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
Nov 20 '05 #2
Hello
I have found my solution. The schema name is case sensitive. I used
lower case, but it will be upper case.
Thanks

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Aleksey | last post: by
3 posts views Thread by drudini | last post: by
bergy
9 posts views Thread by bergy | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.