[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to connect to remote database using swing - oracle t ype 4 driver ?

Posted on 2001-06-08
18
Medium Priority
?
614 Views
Last Modified: 2008-02-01
Using java swing i want to connect the remote database(oracle) and retrive the database from that system. i want to use oracle type 4 driver. To use type 4 driver i need      username/password@hostname:portnumber:sid  
right give me an example of the above parameters. i have a remote system conecting to the internet what are the
parameters i want to expect from remote system?? please help me
0
Comment
Question by:kvkamesh
  • 7
  • 6
  • 2
  • +3
18 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 6167537
This is an example of creatig a connection using an Adabas driver.


public Connection connect() {
Connection con;
// Load driver for connection ...          
try {
      Class.forName("de.sag.jdbc.adabasd.ADriver");
} catch (ClassNotFoundException e) {
      System.out.println("JDBC driver not found");
    };
System.out.println("JDBC driver succesfully loaded.");//******************

try {
// make a connection to database      
       con = java.sql.DriverManager.getConnection(
           "jdbc:adabasd:"+"//"+host+"/"+"MYDB",
        "HARTI","ITRAH");
} catch (java.sql.SQLException e) {
      System.out.println("Error " + e.getErrorCode() +e.getMessage());
      System.exit(0);
};
System.out.println("SQL connection  succesfully started.");
return(con);
}

For your driver modify the lines :
Class.forName("de.sag.jdbc.adabasd.ADriver"); - point the String to your driver path.
con = java.sql.DriverManager.getConnection("jdbc:ORACLE I SUPOSE:"+"//"+HOST IP+"/"+"DATABASE SERVER NAME","DATABASE USER NAME","DATABASE USER PASSWORD");
... and make sure that your driver is in the classpath.
0
 

Expert Comment

by:smileyxx
ID: 6169278
The simple answer is:

jdbc:oracle:thin:USERNAME/PASSWORD@HOST:PORT:SID

where SID is your database identifier, PORT is typically 1521, HOST is hostname or ip address.
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 6174799
And the name of the Driver class is:

oracle.jdbc.driver.OracleDriver

You can also use the getConnection( url, user,password ) method if
specify a url without user/password like this:

jdbc:oracle:thin:@HOST:PORT:SID
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:kvkamesh
ID: 6176142
HI
Thanks for your program. i need what are the parameters i want to pass:- username/password@hostname:portnumber:sid
I have a system no 1 it is connected to modem and it is connected to Internet. right. i have system number 2  is having another modem and it is connected to Internet ok.
Now i am using this string for connecting the oracle database at number 2 system.i am using type 4 driver in the fallowing string what are the parameters i want to pass? jdbc:oracle:thin:USERNAME/PASSWORD@HOST:PORT:SID
what is the username?(may be scott) what is the password? (may be tiger)what is the HOST? (may be hostname or ip address(give me example))what is the Port? (i know it is 1521) what is the SID?
thanks expecting early reply
0
 
LVL 1

Author Comment

by:kvkamesh
ID: 6176150
HI
Thanks for your program. i need what are the parameters i want to pass:- username/password@hostname:portnumber:sid
I have a system no 1 it is connected to modem and it is connected to Internet. right. i have system number 2  is having another modem and it is connected to Internet ok.
Now i am using this string for connecting the oracle database at number 2 system.i am using type 4 driver in the fallowing string what are the parameters i want to pass? jdbc:oracle:thin:USERNAME/PASSWORD@HOST:PORT:SID
what is the username?(may be scott) what is the password? (may be tiger)what is the HOST? (may be hostname or ip address(give me example))what is the Port? (i know it is 1521) what is the SID?
thanks expecting early reply
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 6176560
For username, password port and sid you have to ask the administrator of
the database. port and sid can be found in tnsnames.ora or listener.ora in
$ORACLE_HOME/net/admin

For the hostname or ip you also have to ask the administrator of the system2.
If it has a static ip you can use that, if it has dynamic ip you have to find a way
to exchange this information between the two systems. A possible way is with
a dynamic DNS service, for example www.dhs.org.
0
 
LVL 1

Author Comment

by:kvkamesh
ID: 6176643
ok i got your point for more clarification i am asking you again.i know that what you are explaining.Through LAN i have connected earlier to asking this question,  
jdbc:oracle:thin:scott/tiger@200.100.50.115:1521:orcl (200.100.50.115 this is my system IP)then i connected to my system. Now please tell me in place of IP(200.100.50.115) which Host Name(system IP or Internet Static IP or dynamic IP which ever it is) i want to connect the system no 2 through Internet. Assume that i have 2 systems in one place and i am a administrator. Both systems are connected to Internet through different connection. please help me
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 6176752
OK if I undertood it right you have 2 systems standing in the same room.
There is an ethernet connection between them. Both of these systems
have a modem which connects them to the internet.
The first system has the ip 200.100.50.115 on the ethernet interface.
The second has a similar one on its ethernet interface, for example
200.100.50.116

So there are two ways to connect to the second system:
You can connect over the internet but this makes no sense because
you have a faster connection, over ethernet.
So the better way is just connect to the ethernet ip of system 2
(200.100.50.116 or whatever its ip is).
If there is the same database with the same sid, user etc. then the url is:
jdbc:oracle:thin:scott/tiger@200.100.50.116:1521:orcl

And if you have a private LAN with the ip/netmask 200.100.50.0/255.255.255.0
or similar you should change these ip adresses to one of the private adress
spaces as described in RFC 1918 (http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc1918.html)
These address spaces are:

   10.0.0.0        -   10.255.255.255      (10/8 prefix)
   172.16.0.0    -   172.31.255.255     (172.16/12 prefix)
   192.168.0.0  -   192.168.255.255   (192.168/16 prefix)
0
 
LVL 1

Author Comment

by:kvkamesh
ID: 6176821
HI we are closer.through ethernet we can connect as per your suggestion. i tried earlier only.
 i have given an example for your understanding.acutally i am looking to connect the remote system using this method.I have 2 systems. but both are not connected by ethernet. system no 1 having internet connection and system 2 having internet connection. both are entirely individuals. for testing purpose. for more clear one system is in INDIA and other is in UK or USA.
Now i want to use jdbc:oracle:thin:USERNAME/PASSWORD@HOST:PORT:SID
please tell what is the HOST name i want to mention.
username and password and port, sid we will give as per database i am confusing what we have to write in place of HOST. pleas help me. you understand my problem i want to connect the systems through Internet only. i know through  ethernet we can connect very fast. we are using the same since last 3 months. but i want to connect through Internet only. please help me.thank you for immediate replys
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 6176895
You want to make a connection from the system 1 to the system 2 over
internet and you need the IP of system2 (or hostname).
Now you need to know if the system 2 has a dynamic ip (most of the
users on internet get a dynamic id from their ISP) or a fixed ip.
0
 
LVL 1

Author Comment

by:kvkamesh
ID: 6177017
can u give an example, assume i know their ISP. please the me the example.
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 6177096
Many ISP support both, fixed and dynamic id.
You should ask the administrator of system 2. He can tell you if system 2
has a fixed ip. If it has a fixed ip he can also tell you the hostname or if doesn't
have one the ip address.
If it has a dynamic ip address the administrator of system 2 and you have to find a
way for exchanging the ip address when it changes. There are several ways to do that.
He could send you (or your system) an EMail, he could write it to a file on hes homepage
where you can download the file or he coud setup a script for a dynamic DNS sytem like
www.dhs.org
Sorry that I can't help you anymore, only the administrstor of system 2 can.
0
 
LVL 1

Expert Comment

by:jimsims
ID: 6178311
in pace of HOST you can use either the fully qualified Internet host name (e.g.  data.yourdomain.com) or it's IP address (e.g. 198.0.0.1)  You can use the former if the host in properly in DNS, the latter will be required if you know it's IP address and it's not properly configured in DNS.

so, what you need to know is:  

What is the name of the host if it is in DNS?

or

What is it's IP address?
0
 
LVL 1

Author Comment

by:kvkamesh
ID: 6179961
HI superschlonz
for example sytem IP is 200.100.50.125. And ISP static ID is 100.50.20.2 which one i have to mention in host place?
HI  jimsims
for example sytem IP is 200.100.50.125.And ISP static ID is 100.50.20.2 which one i have to mention in host place?
0
 
LVL 3

Accepted Solution

by:
superschlonz earned 80 total points
ID: 6182919
OK, there are two systems both have a connection to internet and I assume
that both have a connection to their intranet over ethernet. So both systems
have two IP adresses, one for intranet and one for internet.

For example:

System 1 (your system from where you want to make a connection)
Intranet: 200.100.50.115
Internet: 201.100.50.115  (you get this from your ISP)

System 2 (the with the DB you want to connect to)
Intranet: 200.100.50.125
Internet: 202.100.50.125  (the IP address got from it's ISP)

There are two intranets, one where system 1 is and one where system 2 is.
These two intranets are not connected to each other so you cannot connect
from system 1 to IP 200.100.50.125 because there is not routing directly
between these systems.

But you can connect to 202.100.50.125 because both systems have a connection
to internet. (I also assumed that these two systems have two differen ISPs so
I used 201.* for system 1 and 202.* for system 2 )
So your jdbc URL would look like this:

jdbc:oracle:thin:scott/tiger@202.100.50.125:1521:ORCL
0
 
LVL 1

Expert Comment

by:jimsims
ID: 6184140
The HOST parameter is the IP address or hostname of the system the database resides on
0
 
LVL 1

Author Comment

by:kvkamesh
ID: 6185306
HI

Thanks for the same i will try and if connected i will inform you thanks. I have the same idea but i don't have infrastructure to test. Know my idea is exactly matching with your idea. thanks.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9027461
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to supersclonz]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month17 days, 17 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question