If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > JDBC URL to use the hostname syntax

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-31-04, 17:04
sharat1981 sharat1981 is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
JDBC URL to use the hostname syntax

Hi can anyone help me get my java application to connect to a DB2 v8.1 database.

I have a java application that connects just fine to DB2

for my string url i'm using
jdbc:db2:mydatabase
and the driver i'm using is
COM.ibm.db2.jdbc.app.DB2Driver

I'm running the application on the same computer as where my DB2 is installed.

But i dont knw where this 'mydatabase' is created on my computer and how i can use the hostname syntax? and wht is it? So that if needed i can connect to my db from different machine.

Can someone show me how to make a proper connection

thanks
Reply With Quote
  #2 (permalink)  
Old 09-01-04, 02:28
somn somn is offline
Registered User
 
Join Date: Aug 2004
Posts: 3
Smile

You may use the driver "COM.ibm.db2.jdbc.net.DB2Driver",and write the URL like this:"jdbc:db2://hostname:6789/databasename"
Reply With Quote
  #3 (permalink)  
Old 09-01-04, 07:41
sharat1981 sharat1981 is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
Thanks for replying
but where this database will be created on my computer, in which folder?
Can u paste some example code for reference.
Reply With Quote
  #4 (permalink)  
Old 09-01-04, 10:36
n_i n_i is online now
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
It doesn't matter in which folder the database files are: "databasename" in the example given by somn is the name you specify in CREATE DATABASE - it will be cataloged on the server under that name.
Reply With Quote
  #5 (permalink)  
Old 09-01-04, 11:30
sharat1981 sharat1981 is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
But the problem is ,i want to create a database using db2's CLP on my machine and then i wish to connect to that database from my java code using jdbc URL.
And when i create database from CLP and to this DB i try to connect from jdbc it doesnt works and tables r not created in it but somewhere else.
I using db2e drivers to connect to db

String driver = "com.ibm.db2e.jdbc.DB2eDriver";
String url = "jdbc:db2e://localhost:6789/mysample";

SO i would like to knw how i can connect to mysample database from CLP of db2. Normal command
Connect to mysample works but it doesnt show the tables which r created from jdbc.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On