0% found this document useful (0 votes)
43 views

C:/oracle/orahome/jdbc/lib/classes12.jar in The Command Prompt

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)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

C:/oracle/orahome/jdbc/lib/classes12.jar in The Command Prompt

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)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Java oracle table connection using oracle driver 2. Set the java path(path=d:\jdk1.4\bin; !. Search "or classes12.jar 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\classes12.jar

in the

co&&and pro&pt
'. (river)anager.register(river(ne$ oracle.jdbc.driver.*racle(river( ; +. ,o&pile and run the progra&
-. ,onnection cn=(river)anager.get,onnection(.jdbc:oracle:thin:/sakthi:1%21:orcl0.1.scott.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 java.io.6; i&port java.s7l.6; class jtable! 8 public static void &ain(String args9: thro$s 2*45ception1S;<45ception 8 (river)anager.register(river(ne$ oracle.jdbc.driver.*racle(river( ; S=ste&.out.println(.connecting to the database.... ; tr=8 ,onnection cn=(river)anager.get,onnection(.jdbc:oracle:thin:/sakthi:1%21:orcl0.1.scott.1.tiger. ; S=ste&.out.println(.connected to the database.... ; State&ent st=cn.createState&ent( ;

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

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

You might also like