import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Oracle {
public static void main(String[] args) throws SQLException,
ClassNotFoundException {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:test";
String user = "test";
String password = "test";
Connection conn = DriverManager.getConnection(url, user, password);
PreparedStatement ps = conn.prepareStatement("select * from emp");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
System.out.println(rs.getObject(1));
}
rs.close();
ps.close();
conn.close();
}
}