473,418 Members | 2,087 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,418 software developers and data experts.

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 14682
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 ApplicationsDeveloping
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**********@gmail.com> wrote in message
news:5a**************************@posting.google.c om...
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: "Communication 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********************@news20.bellglobal.com >...
"Hassan Naqvi" <ha**********@gmail.com> wrote in message
news:5a**************************@posting.google.c om...
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********************@news20.bellglobal.com >...
"Hassan Naqvi" <ha**********@gmail.com> wrote in message
news:5a**************************@posting.google.c om...
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**********@gmail.com> wrote in message
news:5a**************************@posting.google.c om...
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: "Communication 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
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...
1
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...
3
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...
2
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...
7
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...
1
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....
3
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...
1
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...
2
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
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...
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
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...

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.