473,700 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing DB2 database via Java?

Hi,
Basically, I am Java developer. In past I have played with Oracle
using Java (JDBC). But this is the time to play with IBM DB2 using
Java (JDBC). So kindly help this DB2 newbie.

I have a file of 32 MB, named as "fdbk5.0". This is actually a
database created in DB2 and containing records. I am interested in
viewing the *structure of this database, i.e. table names, column
names and finally all the records. How I can do this? Which DB2
product/version I have to install to view this DB?
Also, it will be highly appreciated, if there is any good info/code
availaible on how to connect DB2 using JDBC API.

Platform: Windows XP and 2000

Thanks in advance.

Truly,
Hassan.
Nov 12 '05 #1
5 14710
I'm a little puzzled. How could you have a DB2 database in a file? Is it
a backup? An export?

As far as Java references, try

Application Development Guide: Building and Running Applications
Application Development Guide: Programming Client Applications
Application Development Guide: Programming Server ApplicationsDev eloping
Enterprise Java Applications Using DB2 Version 8

at http://www-306.ibm.com/software/data...manualsv8.html

Larry Edelstein

Hassan Naqvi wrote:
Hi,
Basically, I am Java developer. In past I have played with Oracle
using Java (JDBC). But this is the time to play with IBM DB2 using
Java (JDBC). So kindly help this DB2 newbie.

I have a file of 32 MB, named as "fdbk5.0". This is actually a
database created in DB2 and containing records. I am interested in
viewing the *structure of this database, i.e. table names, column
names and finally all the records. How I can do this? Which DB2
product/version I have to install to view this DB?
Also, it will be highly appreciated, if there is any good info/code
availaible on how to connect DB2 using JDBC API.

Platform: Windows XP and 2000

Thanks in advance.

Truly,
Hassan.


Nov 12 '05 #2

"Hassan Naqvi" <ha**********@g mail.com> wrote in message
news:5a******** *************** ***@posting.goo gle.com...
Hi,
Basically, I am Java developer. In past I have played with Oracle
using Java (JDBC). But this is the time to play with IBM DB2 using
Java (JDBC). So kindly help this DB2 newbie.

I have a file of 32 MB, named as "fdbk5.0". This is actually a
database created in DB2 and containing records. I am interested in
viewing the *structure of this database, i.e. table names, column
names and finally all the records. How I can do this? Which DB2
product/version I have to install to view this DB?
Also, it will be highly appreciated, if there is any good info/code
availaible on how to connect DB2 using JDBC API.

Platform: Windows XP and 2000

I am also a Java developer and I have written a number of Java programs that
operate against a DB2 database via JDBC.

Assuming that your file 'fdbk5.0' is a normal backup of a DB2 database, you
will need to restore it to a live DB2 database somewhere before you can
access it with Java. Do you know what version of DB2 took this backup?
Normally, you restore a database to a copy of DB2 that is at the same
version as when the backup was taken. Therefore, if you backup up a DB2 V6.0
database, you restore that backup to a DB2 V6.0 database.

It is usually possible to restore older databases to a newer version of DB2
but this can be quite involved since the record formats often change from
version to version; that means that an older database has to be converted,
sometimes repeatedly, to bring it up the version of DB2 that you are
running. Therefore, if your backup is from a DB2 V6.0 system and you want to
run it in DB2 V8.x, you will need to restore and convert it. (I don't recall
if you have to convert it from V6.0 to V7.x and then from V7.x to V8.x or if
you can convert it from V6.0 directly to V8.x.)

If you don't know what version of DB2 created your backup, there may be some
way to determine this from the 'fdbk5.0' file itself, although I don't know
how myself. I looked through one of my backups and didn't see an obvious
version number but it was a huge file and I could easily have missed it.

You should probably install a current version of DB2 for Windows, either
V8.1 or the new (beta) V8.2, and then attempt to restore your backup into
it. It probably won't work but the error messages should help you figure out
which version the backup is so that you can figure out which conversions
need to be done to make your restore successful.

When you have installed DB2, use the documentation provided to read about:
- 'Migration' from previous versions of DB2.
- the Restore command
- Java application development. I think you'll find the Java sample programs
particularly useful for finding out how to connect to a DB2 database from a
Java program.

You can see the DB2 documentation for V8.2 online at
http://publib.boulder.ibm.com/infoce...help/index.jsp if you want to
read it before installing DB2.

Rhino


Nov 12 '05 #3
Hi,
Yes, this a *backup which I took on DB2 V8.1.2 using command:
"BACKUP DATABASE fdbk50 to c:\mybackup". This means, I have to
*restore "fdbk50" on same version using Restore command. Now the real
question is:

1: "Connection b/w my Java application and fdbk50" AND
2: "Communicat ion b/w my Java application and fdbk50".

At this stage, it will be highly appreciated if someone provides some
usefull information, specially code snippets on boths questions. Also
for the 2nd question, what are the SQL queries for DB2?

Truly,
Hassan.

"Rhino" <rh****@NOSPAM. sympatico.ca> wrote in message news:<45******* *************@n ews20.bellgloba l.com>...
"Hassan Naqvi" <ha**********@g mail.com> wrote in message
news:5a******** *************** ***@posting.goo gle.com...
Hi,
Basically, I am Java developer. In past I have played with Oracle
using Java (JDBC). But this is the time to play with IBM DB2 using
Java (JDBC). So kindly help this DB2 newbie.

I have a file of 32 MB, named as "fdbk5.0". This is actually a
database created in DB2 and containing records. I am interested in
viewing the *structure of this database, i.e. table names, column
names and finally all the records. How I can do this? Which DB2
product/version I have to install to view this DB?
Also, it will be highly appreciated, if there is any good info/code
availaible on how to connect DB2 using JDBC API.

Platform: Windows XP and 2000

I am also a Java developer and I have written a number of Java programs that
operate against a DB2 database via JDBC.

Assuming that your file 'fdbk5.0' is a normal backup of a DB2 database, you
will need to restore it to a live DB2 database somewhere before you can
access it with Java. Do you know what version of DB2 took this backup?
Normally, you restore a database to a copy of DB2 that is at the same
version as when the backup was taken. Therefore, if you backup up a DB2 V6.0
database, you restore that backup to a DB2 V6.0 database.

It is usually possible to restore older databases to a newer version of DB2
but this can be quite involved since the record formats often change from
version to version; that means that an older database has to be converted,
sometimes repeatedly, to bring it up the version of DB2 that you are
running. Therefore, if your backup is from a DB2 V6.0 system and you want to
run it in DB2 V8.x, you will need to restore and convert it. (I don't recall
if you have to convert it from V6.0 to V7.x and then from V7.x to V8.x or if
you can convert it from V6.0 directly to V8.x.)

If you don't know what version of DB2 created your backup, there may be some
way to determine this from the 'fdbk5.0' file itself, although I don't know
how myself. I looked through one of my backups and didn't see an obvious
version number but it was a huge file and I could easily have missed it.

You should probably install a current version of DB2 for Windows, either
V8.1 or the new (beta) V8.2, and then attempt to restore your backup into
it. It probably won't work but the error messages should help you figure out
which version the backup is so that you can figure out which conversions
need to be done to make your restore successful.

When you have installed DB2, use the documentation provided to read about:
- 'Migration' from previous versions of DB2.
- the Restore command
- Java application development. I think you'll find the Java sample programs
particularly useful for finding out how to connect to a DB2 database from a
Java program.

You can see the DB2 documentation for V8.2 online at
http://publib.boulder.ibm.com/infoce...help/index.jsp if you want to
read it before installing DB2.

Rhino

Nov 12 '05 #4
Hello,

The file "fdbk50" is a backup file taken on IBM DB2 V8.1.2. My two
major tasks are:

1: Connecting my Java application with IBM DB2 V 8.1.2 using JDBC API
2: SQL queries for IBM DB2 so that I can interact with fdbk50.

Any help on above two tasks will be higly appreciated. Specially
any good info/code on 1st task.

Truly,
Hassan.

"Rhino" <rh****@NOSPAM. sympatico.ca> wrote in message news:<45******* *************@n ews20.bellgloba l.com>...
"Hassan Naqvi" <ha**********@g mail.com> wrote in message
news:5a******** *************** ***@posting.goo gle.com...
Hi,
Basically, I am Java developer. In past I have played with Oracle
using Java (JDBC). But this is the time to play with IBM DB2 using
Java (JDBC). So kindly help this DB2 newbie.

I have a file of 32 MB, named as "fdbk5.0". This is actually a
database created in DB2 and containing records. I am interested in
viewing the *structure of this database, i.e. table names, column
names and finally all the records. How I can do this? Which DB2
product/version I have to install to view this DB?
Also, it will be highly appreciated, if there is any good info/code
availaible on how to connect DB2 using JDBC API.

Platform: Windows XP and 2000

I am also a Java developer and I have written a number of Java programs that
operate against a DB2 database via JDBC.

Assuming that your file 'fdbk5.0' is a normal backup of a DB2 database, you
will need to restore it to a live DB2 database somewhere before you can
access it with Java. Do you know what version of DB2 took this backup?
Normally, you restore a database to a copy of DB2 that is at the same
version as when the backup was taken. Therefore, if you backup up a DB2 V6.0
database, you restore that backup to a DB2 V6.0 database.

It is usually possible to restore older databases to a newer version of DB2
but this can be quite involved since the record formats often change from
version to version; that means that an older database has to be converted,
sometimes repeatedly, to bring it up the version of DB2 that you are
running. Therefore, if your backup is from a DB2 V6.0 system and you want to
run it in DB2 V8.x, you will need to restore and convert it. (I don't recall
if you have to convert it from V6.0 to V7.x and then from V7.x to V8.x or if
you can convert it from V6.0 directly to V8.x.)

If you don't know what version of DB2 created your backup, there may be some
way to determine this from the 'fdbk5.0' file itself, although I don't know
how myself. I looked through one of my backups and didn't see an obvious
version number but it was a huge file and I could easily have missed it.

You should probably install a current version of DB2 for Windows, either
V8.1 or the new (beta) V8.2, and then attempt to restore your backup into
it. It probably won't work but the error messages should help you figure out
which version the backup is so that you can figure out which conversions
need to be done to make your restore successful.

When you have installed DB2, use the documentation provided to read about:
- 'Migration' from previous versions of DB2.
- the Restore command
- Java application development. I think you'll find the Java sample programs
particularly useful for finding out how to connect to a DB2 database from a
Java program.

You can see the DB2 documentation for V8.2 online at
http://publib.boulder.ibm.com/infoce...help/index.jsp if you want to
read it before installing DB2.

Rhino

Nov 12 '05 #5

"Hassan Naqvi" <ha**********@g mail.com> wrote in message
news:5a******** *************** ***@posting.goo gle.com...
Hi,
Yes, this a *backup which I took on DB2 V8.1.2 using command:
"BACKUP DATABASE fdbk50 to c:\mybackup". This means, I have to
*restore "fdbk50" on same version using Restore command. Now the real
question is:

1: "Connection b/w my Java application and fdbk50" AND
2: "Communicat ion b/w my Java application and fdbk50".

At this stage, it will be highly appreciated if someone provides some
usefull information, specially code snippets on boths questions. Also
for the 2nd question, what are the SQL queries for DB2?

You won't be connecting directly to fdbk5.0: you will be connecting to the
restored database. That's very important for you to realize.

In short, you simply load your JDBC driver and then connect to the database;
once you have done that, you issue the SQL statements you want to execute.

To see examples, go to
http://publib.boulder.ibm.com/infoce...help/index.jsp and specify the
following in the 'Search:" box on that page: JDBC Samples

Press the 'Go' button. From the resulting list of hits in the left-hand
pane, select 'JDBC Samples' which should be the second item in the list. A
summary page listing a large number of JDBC examples will appear in the
right-hand pane of the page. Click on any of them to see the code in that
sample program. For instance, DbConn.java shows you how to connect to a
database.

You will also have these same examples in your copy of DB2 in the
SQLLIB\samples\ java\jdbc directory. You can prepare and run these examples
if you like. Instructions on how to do so are in the manuals.

Rhino
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3585
by: Generic Usenet Account | last post by:
I am trying to create a Java application that reads a list of URLs from a file and stores their contents on the local file system. I have succeeded in accessing normal websites, but I am unable to access the secured websites (using the HTTPS protocol) using this approach. I would greatly appreciate if someone could suggest a way out. I have looked at the HttpsURLConnection class, but unfortunately this class is abstract.
1
1475
by: wnstnsmith | last post by:
Dear all, Maybe I'm stupid, in any case I'm stupefied by now. Please help. Stored procedures in Access should be accessible from a java-applet throught a callable statement, but all I get is error messages from Access, which tell me nothing. Can anybody tell me what is wrong with the following:
3
4318
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different geographical locations. I have been completely unsucessful in acheiving this goal so far however. Things I have tried: Create a shortcut to ftp sight via browser then tried to map local drive to
2
2477
by: Mike | last post by:
..NET framework 1.2 Hello. We've been accessing a Java COM component from classic ASP for a while now, which works fine. We now need to access it from .NET, but we have no idea how to reference this component as we can't find the .dll (or whatever type of file Java COM components compile to). We do know a couple of things about the component:
7
7110
by: David Laub | last post by:
I've also posted this issue to a Sun/java formum, but since it appears to be an integration issue, this may be the better place to posr: I have written a dot net/c# Web Services doesn't fully work with J2ME client a) c# web service works with c# WIndows Client (local & remote web service) b) c# web service works with J2ME client - when the Web Service is local c) c# web service fails with J2ME client - when the Web Service is remote ...
1
1671
by: srpatna | last post by:
I am trying to access Web Service of a Vendor. Its built using Java on Weblogic. Connection is restricted to users with client certificate provided by them and NOT from any recognised authority. The Web Service setup at the vendor does not allow us to browse the wsdl or xsd. They have provided us the wsdl for to use. My problem is I am unable to compile the wsdl using wsdl.exe because it gives
3
2685
by: Pakna | last post by:
Hello, I have what may be a beginner's question regarding DB2. How does one access a remote table on a remote database via SQL? What is the command string, is there an equivalent of Oracle DBLINK? I hope I was clear. If there are more information that I need to supply, please do tell me. Thank you very much for your replies
1
1796
by: Lyndon | last post by:
Hi all, I am developing an Access database application that requires some additional, non-database related functionality. This additional functionality is essentially to validate a flat text file provided by an external data provider. I am proposing to add a button to one of the forms in my application to perform this validation and then pop up a message box indicating whether the flat file is valid or not. This is in preference to...
2
5780
by: Adman | last post by:
All, I am experiencing an issue that has confused me, albiet this is not difficult to do. Any help anyone could provide would be greatly appreciated. After our jdbc calls received the following error: com.ibm.db2.jcc.a.SqlException: DB2 SQL error: SQLCODE: -805, SQLSTATE: 51002, SQLERRMC: NULLID.SYSLH203 0X5359534C564C3031
0
8714
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
8641
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9203
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9060
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
8912
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...
1
6557
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
5897
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
4650
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3082
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

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.