Here is another way to connect to Oracle.
/***************** Start *************/
private Connection openConnection() {
Connection connection = null;
try {
// Register the database driver.
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver() );
// Attempt to open a connection to the database.
connection =
DriverManager.getConnection(
"jdbc:oracle:thin:123.45.678.90:1521:SID_NAME" ,
"USERNAME",
"PASSWORD" );
}
catch( Exception e ) {
System.out.println( e.getMessage() );
}
return connection;
}
/***************** End *************/
Match
At 3/30/99 02:35 PM, [EMAIL PROTECTED] wrote:
>
>Here is a code snipplet that I use for connecting to an oracle rdbm
>
>you may have to alter it somewhat to get it to work right for you, but I do
>believe that with a little study you will have no problems.
>
>~~ FYI: Oracle is probalby the hardest database to connect to ~~
>
>
>/***************** S T A R T - C O D E *************/
>
>import java.sql.*;
>import com.informix.jdbc.IfxDriver;
>import oracle.jdbc.driver.*;
>import java.math.*;
>
>
>public class Conn{
>
> Connection CurrConn;
> String Driver= new String();
> String Host,Service,Dbase,Server,User,Pword,Dns;
>
> public Conn(){
> try{
> DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
> }catch(Exception e){System.out.println("ORACLE DRIVER LOADER ERROR: " +
e);}
> }//end constructor
>
> private void setOracleConnection() { //throws Exception
> try{
> Class.forName(Driver);
> Connection conn = DriverManager.getConnection (
>"jdbc:oracle:thin:123.45.678.90:1521:SID_NAME","USER", "PASSWORD");
> }catch(Exception e){System.out.println("ORACLE ERROR: " + e);
>e.printStackTrace();}
>}//end getInformixConnection
>
>}//end Conn class
>
>/***************** F I N I S H - C O D E *************/
>
>Steve Gee
>Java Developer
>Maxor National Pharmacies
>Information Technologies
>
>[EMAIL PROTECTED]
>806.324.5540
>www.maxor.com
>806.324.5400
>
>
>
>----------------------------------------------------------------------
>To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]