/* * This sample shows how to list all the names from the EMP table * * It uses the JDBC THIN driver. See the same program in the * oci7 or oci8 samples directories to see how to use the other drivers. */ // For JDBC Thin in JDK-1.0.2 we recommend importing the jdbc.sql package // instead of the java.sql package. This is stricly necessary only for // Applets. // You need to import the jdbc.sql package to use JDBC import jdbc.sql.*; class Employee { public static void main (String args []) throws SQLException, ClassNotFoundException { // Load the Oracle JDBC driver // When you import jdbc.sql the driver is in the package // oracle.jdbc.dnlddriver Class.forName ("oracle.jdbc.dnlddriver.OracleDriver"); // Connect to the database // // You must put a database name after the @ sign in the connection URL. // You can use either the fully specified SQL*net syntax or a short cut // syntax as ::. The example uses the short cut syntax. // // When you import jdbc.sql the driver name is dnldthin Connection conn = DriverManager.getConnection ("jdbc:oracle:dnldthin:@dlsun511:1721:dbms733", "scott", "tiger"); // Create a Statement Statement stmt = conn.createStatement (); // Select the ENAME column from the EMP table ResultSet rset = stmt.executeQuery ("select ENAME from EMP"); // Iterate through the result and print the employee names while (rset.next ()) System.out.println (rset.getString (1)); } }