❮ Previous Next ❯

Connecting to Oracle Database

For connecting java application with the oracle database, we need to follow the above steps . Here I am using Oracle10g as the database. So we need to know following information for the oracle database:

Let's see an example to retrieve all the records of employee table. So we have to first create a table in oracle database, then inserting some records, then writing a jdbc application to retrieve records from oracle database.

//Creating table
create table employee
id number(10),
name varchar2(40),
sal number(7)
inserting a record
insert into employee values(101,'Tapuuu',15000);
//JDBC Program
import java.sql.*;
class JdbcDemo
public static void main(String args[ ]) throws Exception
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "password");
Statement st=conn.createStatement( );
ResultSet rs = rs.executeQuery("select * from employee");
while(rs.next( ))
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
con.close( );
101 Tapuuu 15000 Note:

To connect java application with the Oracle database, ojdbc14.jar file is required to be loaded.

❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved