Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / November 2005

Tip: Looking for answers? Try searching our database.

JDBC: DatabaseMetaData

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Maroon - 20 Nov 2005 08:41 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.