Link to home
Start Free TrialLog in
Avatar of sunitha
sunitha

asked on

Accessing Oracle Database from JAVA?

The setup is as follows:
The webserver (internet host server) is in the USA. There is a page for online resume.

The database server (Oracle 8) is in Bangalore, India.

Both these locations have a 64kbps leased line.

When the online resume page is accessed via internet and the resume is submitted after keying in all the details, the data keyed in should get inserted/updated into the database in Bangalore.

Is it possible?

If Yes, How to do it?

If No, any alternatives?
Avatar of Ravindra76
Ravindra76


Hi, Try with this

 Class.forName("oracle.jdbc.driver.OracleDriver")

conn = DriverManager.getConnection
             ("jdbc:oracle:thin:@"+x.getOraIP()+":"+
                    x.getOraPort()+":"+x.getOraSID(),
                    x.getOraLogin(),    
              x.getOraPass());

x is a file where your will store private variables and public methods like

    private static String oracleServerIP = "xxx.xxx.xxx.xxx";
    private static String oraclePort = "1521";
    private static String oracleSID = "1521";
    private static String oracleLogin = "name"
    private static String oraclePassword = "password"




 public static String getOraIP(){
        return oracleServerIP;
    }

    public static String getOraPort(){
        return oraclePort;
    }

    public static String getOraSID(){
        return oracleSID;
    }

    public static String getOraLogin(){
        return oracleLogin;
    }

    public static String getOraPass(){
        return oraclePassword;
    }

   
Avatar of sunitha

ASKER

ravindra76:

I have this code with me already and it is working fine.

Let me make it clear to you that the database connection is via the internet from the USA server to my Bangalore server.

Technical details:
The web server and my servlet is on the USA server.

The Oracle database is here in Bangalore.

when I post the online form to my servlet, the details entered in the form should be saved in the oracle tables which is in Bangalore.

with the code u have given I should have a registered IP address for the machine on which the oracle server is installed.

If I have a registred IP address I am leaving the oracle server open to the internet which I dont want to do.
 
You must have registered ip address for the oracle server.

The same thing. we are doing by putting oracel server in
one machine and webserver in another machine. both are
connected through internet 64kbps line. The servlet which is
invoked from the webserver with  some ipaddress,
will connect to database server through the oracleserver ip address and store the all details entered by the user .
You must have registered ip address for the oracle server.

The same thing. we are doing by putting oracel server in
one machine and webserver in another machine. both are
connected through internet 64kbps line. The servlet which is
invoked from the webserver with  some ipaddress,
will connect to database server through the oracleserver ip address and store the all details entered by the user .
You must have registered ip address for the oracle server.

The same thing. we are doing by putting oracel server in
one machine and webserver in another machine. both are
connected through internet 64kbps line. The servlet which is
invoked from the webserver with  some ipaddress,
will connect to database server through the oracleserver ip address and store the all details entered by the user .
>> If I have a registred IP address I am leaving the oracle server

you need either internet connection (registered IP address) or LAN connection (Oracle server is behind a firewall)
ASKER CERTIFIED SOLUTION
Avatar of rsalgado
rsalgado

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial