Connecting Java program to DB2 on Linux
Hello,
I'm using DB2 on Linux (RedHat 7.1) and I wish to connect to the database
from a Java program. In Windows, I know to go to the control panel and define
a DSN. How do I do this in Linux?
Thanks,
Jason Williams
jwilliams@wc-group.com
# 1 Re: Connecting Java program to DB2 on Linux
>I'm using DB2 on Linux (RedHat 7.1) and I wish to connect to the database
>from a Java program. In Windows, I know to go to the control panel and
define
>a DSN. How do I do this in Linux?
Use these context properties:
USERNAME=your user name
DRIVER=COM.ibm.db2.jdbc.net.DB2Driver
PASSWORD=your user's password
URL=jdbc:db2://server_host_name:server_port/shema_name
server_port is set by using "db2jstrt server_port"; and
the port typically used is 50000. I also used 50001, etc.
Make sure you have the Java clients classpath include db2java.zip
which contian the db2 net drivers.
You can also connect using type 2 but your client has to have the
db2 libs in its path. And you will have to use db2's client configuration
tool to set up and define the connection.
Hope this helps.