import java.sql.*; import oracle.jdbc.pool.OracleDataSource; public class Drive1Oracle10 { public static void main (String args []) throws SQLException { Connection connection; // Database Connection Object try { // Create a OracleDataSource instance OracleDataSource ods = new OracleDataSource(); ods.setURL("jdbc:oracle:oci:@"); // Sets the database name ods.setDatabaseName("orcl"); // Sets the user name ods.setUser("scott"); // Sets the password ods.setPassword("tiger"); Connection conn = ods.getConnection(); // Create a Statement Statement stmt = conn.createStatement (); // Select the ENAME column from the EMP table ResultSet rset = stmt.executeQuery ("select * from dept"); // Iterate through the result and print the employee names while (rset.next ()) System.out.println (rset.getString (1)); // Close the RseultSet rset.close(); // Close the Statement stmt.close(); // Close the connection conn.close(); } catch(SQLException ex) {} } } /* PreparedStatement pstmt = null; pstmt = conn.prepareStatement("insert into result values (?, ?)"); pstmt.setInt(1, 34); pstmt.setString(2, "data34"); pstmt.addBatch(); pstmt.executeBatch(); */