Recent Posts
- NCC Punjab LDC Results 2013 NCCPunjab.com Interview Selected Candidates List
- RGUHS PGSSET Super Speciality 2013 Exam www.logisys.net.in Online Application
- RKCL RS-CIT Results 2013 rkcl.in RSCIT Final Exam May Result 2013
- TNEB Electricity Bills Online Payment tnebnet.org/awp/login Tamilnadu EB Payment System
- Kerala LET 2013 Fee Structure for 2013-14 Engineering College Admission
Discussion Forum
ResultSet in Java Example Program
ResultSet in Java example JDBC Concepts. This Java ResultSet DB (database) example describes the basic operations performed on the JDBC ResultSet database connectivity code.
ResultSet in Java example JDBC Concepts. This Java ResultSet DB (database) example describes the basic operations performed on the JDBC ResultSet database connectivity code.In this example you will learn about how to write java code for ResultSet with oracle database.
Program:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class ResultSetDemo {
public static void main(String args[]){
Connection con=null;
Statement st = null;
try {
Class.forName(“oracle.jdbc.driver.OracleDriver”);
con=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:ORCL”,”scott”,”tiger”);
st = con.createStatement();
ResultSet rs = st.executeQuery(“select * from eshusoft”);
while(rs.next()){
String userName= rs.getString(1);
String password = rs.getString(2);
System.out.println(“userName: “+userName);
System.out.println(“password: “+password);
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Result:
username : myuser
password : mypwd
