473,756 Members | 5,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JDBC: DatabaseMetaDat a



import java.sql.*;

public class TESTA{

TESTA(){}

public static int product() {

try {
Class.forName(" com.ibm.db2.jcc .DB2Driver");
} catch (ClassNotFoundE xception e) {
e.printStackTra ce();
}

try{
String url = "jdbc:db2://192.168.2.3:500 00/coffee:";
System.out.prin tln("Before the Connection");
Connection con =
DriverManager.g etConnection(ur l,"jence_user", "jence_db") ;

DatabaseMetaDat a dbmd=con.getMet aData();
String[] types = {"TABLE"};
ResultSet rset=dbmd.getTa bles(null,"jenc e_user","%",typ es);

while(rset.next ()){
System.out.prin tln("Table Name
"+rset.getStrin g("TABLE_NAME") );
}

return 0;

}catch(Exceptio n e){
e.printStackTra ce();
return -1; //it represent the error has occured
}

}

public static void main(String argv[]){
System.out.prin tln("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 3468
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 ResultSetMetaDa ta 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ämpf e
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
7256
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 get the following error trace, DriverManager.initialize: jdbc.drivers = null JDBC DriverManager initialized SQLException: SQLState(08S01) {sql7=true, port=1433, user=sa, url=jdbc:inetdae7:US0211737-WP01:1433,
1
4501
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 ru_RU.KOI8-R locale. All the databases were created with KOI8-R encoding. No problems were encountered in accessing database table data with JDBC.
3
3774
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 types, NOT NULLness, PK, FK, and unique indexes. But one thing that I can't seem to extract is info
4
6465
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 JDBC. Assume we have a table named "test". Under PSQL, we can input "\d test" to see the details about table "test" successufully. However, my main purpose is trying to get column name, column name of a table through JDBC.
15
2468
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 would be grateful for any discussion of this! thanks, Joe Weinstein at BEA Systems Results on Linux Box -----------------------------------------------------------------------
3
1928
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 different version/build then the DB version itself. Thanks, Bob Cook
1
5075
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 alternatively is there any special syntax in the getProcedures method to limit the results to procedures belonging to the current schema? Is there any clear documentation about the interpretation to be given to catalog and schema in DB2's JDBC...
2
8626
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: " +metadata.getDriverVersion()); System.out.print("JDBC version: " + metadata.getJDBCMajorVersion()); System.out.println("." +metadata.getJDBCMinorVersion());
9
3254
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 but all of their examples use the DriverManager. Something like: conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" + "user=monty&password=greatsqldb"); Does anyone know of any modules that...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.