• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Accessing Database

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I need to retrieve data from an Oracle database(on a unix machine) from another linux machine in the same network? Can anyone give me some ideas how I can do it? Using ordinary Java programs can do?
Thanks
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here you find the Oracle doc describing the way to create a connection.
In the getconnection "Myhos"t can be all oracle servers on your network. you can either set the ip address for this field!


Specifying a Database URL, User Name, and Password
The following signature takes the URL, user name, and password as separate parameters:
getConnection(String URL, String user, String password);

Where the URL is of the form:
jdbc racle:<drivertype>:@<database>

The following example connects user scott with password tiger to a database with SID orcl through port 1521 of host myhost, using the Thin driver.
Connection conn = DriverManager.getConnection
("jdbc racle:thin:@myhost:1521 rcl", "scott", "tiger");

If you want to use the default connection for an OCI driver, specify either:
Connection conn = DriverManager.getConnection
("jdbc racle ci8:scott/tiger@");
or:
Connection conn = DriverManager.getConnection
("jdbc racle ci8:@", "scott", "tiger");

For all JDBC drivers, you can also specify the database with a Net8 keyword-value pair. The Net8 keyword-value pair substitutes for the TNSNAMES entry. The following example uses the same parameters as the preceding example, but in the keyword-value format:
Connection conn = DriverManager.getConnection
(jdbc racle ci8:@MyHostString","scott","tiger");

or:
Connection conn = DriverManager.getConnection
("jdbc racle ci8:@(description=(address=(host= myhost)
(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))","scott", "tiger");



------------------
Benjamin l�onard
www.evisor.com
[This message has been edited by Benjamin Leonard (edited May 25, 2001).]
 
Sita Yo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's right! But I need to load the driver first using:
Class.forName("sun.jdbc.odbc.OracleDriver");
However it got another message:
java.lang.ClassNotFoundException: sun/jdbc/odbc/OracleDriver
I think I don't have the Oracle drive in my machine. How can I install the Oracle driver in the linux machine??
Can anyone help me?!
Thanks
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Get the Oracle cd from Oracle. When you load Oracle the driver comes with it. You need a license to use it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic