Solved

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

Posted on 2001-06-08
18
578 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:kvkamesh
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:superschlonz
Comment Utility
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
Comment Utility
can u give an example, assume i know their ISP. please the me the example.
0
 
LVL 3

Expert Comment

by:superschlonz
Comment Utility
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
Comment Utility
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
Comment Utility
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 20 total points
Comment Utility
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
Comment Utility
The HOST parameter is the IP address or hostname of the system the database resides on
0
 
LVL 1

Author Comment

by:kvkamesh
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now