By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,334 Members | 1,328 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,334 IT Pros & Developers. It's quick & easy.

Accessing DB2 database via Java?

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.