0% found this document useful (0 votes)
124 views2 pages

Java-Oracle DB Connection Guide

1. This document provides steps to connect to an Oracle database from Java: set the Java path, set the classpath to Oracle JDBC drivers, register the Oracle driver, get a database connection. 2. It includes two example programs - one to drop a table and one to select from the dual table to test the connection. Both programs get a connection, execute a statement, handle exceptions. 3. The steps and examples show how to configure the Java environment and write code to successfully connect to an Oracle database from a Java program.

Uploaded by

vel.sakthi3152
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views2 pages

Java-Oracle DB Connection Guide

1. This document provides steps to connect to an Oracle database from Java: set the Java path, set the classpath to Oracle JDBC drivers, register the Oracle driver, get a database connection. 2. It includes two example programs - one to drop a table and one to select from the dual table to test the connection. Both programs get a connection, execute a statement, handle exceptions. 3. The steps and examples show how to configure the Java environment and write code to successfully connect to an Oracle database from a Java program.

Uploaded by

vel.sakthi3152
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

1. Java oracle table connection using oracle driver 2. Set the java path(path=d:\jdk1.4\bin; !. Search "or [Link] or classes12.

#ip or ojdbc14.#ip $ithin oracle installation "older 4. Set the classpath to the oracle installation "older %. Set classpath=.;c:\oracle\oraho&e\jdbc\lib\[Link]

in the

co&&and pro&pt
'. (river)[Link](river(ne$ [Link].*racle(river( ; +. ,o&pile and run the progra&
-. ,onnection cn=(river)[Link],onnection(.jdbc:oracle:thin:/sakthi:1%21:[Link].1. tiger. ; 0. 2n the start &enu choose oracle and in con"iguration and &igration tools go to 3et)anager and there look "or hostna&e and portnu&ber and use that in get,onnection ( code.

45:1 progra&
i&port [Link].6; i&port java.s7l.6; class jtable! 8 public static void &ain(String args9: thro$s 2*45ception1S;<45ception 8 (river)[Link](river(ne$ [Link].*racle(river( ; S=ste&.[Link](.connecting to the database.... ; tr=8 ,onnection cn=(river)[Link],onnection(.jdbc:oracle:thin:/sakthi:1%21:[Link]. ; S=ste&.[Link](.connected to the database.... ; State&ent st=[Link]&ent( ;

st.e5ecute>pdate(.drop table trans. ; S=ste&.[Link](.?able trans dropped. ; @catch(S;<45ception e5 8 S=ste&.[Link](.?he e5ception raised is:.Ae5 ; @ @ @

45:2 progra&
i&port [Link].6; i&port java.s7l.6; class jtable1 8 public static void &ain(String args9: thro$s 2*45ception1S;<45ception 8 (river)[Link](river(ne$ [Link].*racle(river( ; S=ste&.[Link](.connecting to the database.... ; tr= 8 ,onnection cn=(river)[Link],onnection(.jdbc:oracle:thin:/sakthi:1%21:[Link]. ; State&ent st=[Link]&ent( ; BesultSet rs=st.e5ecute;uer=(.select CconnectedC "ro& dual. ; rs.ne5t( ; String s=[Link](1 ; S=ste&.[Link](s ; [Link]( ; [Link]( ; @ catch(45ception e5 8 S=ste&.[Link](.?he e5ception raised is:.Ae5 ; @ @ @

You might also like