473,396 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3445
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Swami | last post by:
Hi, I have installed MQ SQL Server 2000 on my laptop and trying to use SPRINTA 2000 JDBC Driver (inetmssql.jar) to connect to the local db. I wrote a sample Java app to test the connection and I...
1
by: Aleksey | last post by:
Hello, I have the following problem working with DatabaseMetaData. There is a database with table and attribute names in Russian. Database cluster was initialized with appropriate...
3
by: aj | last post by:
Red Hat AS 2.1 DB2 WSE v8.1 FP5 Type 4 DB2 JDBC driver Using java.sql.DatabaseMetaData and ResultSetMetaData, I've written a JDBC/Java utility that shows, table by table, columns & their...
4
by: Ying Lu | last post by:
Hello, Under mysql, we have "desc tablename" to get the detail information about a table. My question is about to get column name, and column type for a specific table under PostgreSQL through...
15
by: Joe Weinstein | last post by:
Hi. Below is a simple JDBC program to insert and extract a numerical value. When ResultSet.getDouble() is called, the same program produces different output on solaris than it does on Linux. I...
3
by: drudini | last post by:
We have installed DB2UDB 8.2 on a windows 2003 server. How can I confirm the version of the JDBC driver that would have been installed with this? I wasn;t sure if the JBDC driver would have a...
1
by: Pete Geraghty | last post by:
I want to use DatabaseMetadata to retrieve details of those stored procedures which belong to the current schema. How can I find out what is the current schema for an existing Connection? Or...
2
by: dvawdrey | last post by:
Can someone help me please with the following code: try { DatabaseMetaData metadata=con.getMetaData(); System.out.println(metadata.getDriverName()); System.out.println("Driver version:...
9
bergy
by: bergy | last post by:
I am writing on an embedded device (J9 framework from IBM) that has a partial version of the java.sql package. It does not include Driver or DriverManager. I have downloaded the mysql Connector/J...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.