Write a java program that connects to oracle database, queries the inbuilt table “emp” and displays the first two columns (empno using column index and ename using column name ) of all the rows.
Write a java program that connects to oracle database, queries the inbuilt table “emp” and displays the first two columns …
Share
try {
Class.forName(“oracle.jdbc.driver.OracleDriver”);
conn = DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:XE”, “JAMES”, “local”);
} catch (Exception e) {
System.out.println(“Connection could not be established”);
if (conn != null) conn.close();
}
ANSWER :