Retrieving the records from Oracle database using Java
To get/retrieve the records from the Oracle database we have to write a java application program which will get the record from the database.
Steps: Step 1: Creating the “Emp” table in database. create table Emp(eno integer,ename varchar(20),sal float);
Step 2: Inserting the record into table. insert into Emp values(101,’Santosh’,25000); insert into Emp values(102,’Sandeep’,21000); Step 3: Write a program & save it with name “oracledata.java” in jdk folder. // Program to retrieve the record from database import java.sql.*; class oracledata { public static void main(String args[]) throws Exception { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver( )); Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe","system","tiger"); Statement stmt=con.createStatement( ); ResultSet rs=stmt.executeQuery("select * from Emp"); while(rs.next( )) { System.out.println("===================="); System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)); }
con.close( ); } }
Step 4: Execution of Program: Compile the program. javac oracledata.java Run the program java oracledata
Output:
After successful execution of the program we will get the above output, it means the “Emp” table has two records.
Retrieving the records from Oracle database using Java.pdf
Retrieving the records from Oracle database using Java.pdf. Retrieving the records from Oracle database using Java.pdf. Open. Extract. Open with. Sign In.
Using xDB to Offload Oracle Reporting Database to Postgres-script-2.pdf. Using xDB to Offload Oracle Reporting Database to Postgres-script-2.pdf. Open.
Database Systems Using Oracle: United States Edition PDF, Read Online Database Systems ... understand and utilize Oracle 9i architecture and administration.
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Updating a ...
Database Systems Using Oracle: United States Edition PDF, Read Online Database Systems ... understand and utilize Oracle 9i architecture and administration.