// File: Jdbc1.java (Module 14) // // Author: Rahul Simha // Created: December 9, 1998 // // Illustrates JDBC import java.net.*; import java.sql.*; import java.io.*; public class Jdbc1 { public static void main (String[] argv) { try{ // First, load the "SequeLinkDriver" class. Class.forName ("intersolv.jdbc.sequelink.SequeLinkDriver"); // Now prepare the strings needed to make the connection. System.out.println ("WARNING: password not entered"); String connection_url = "jdbc:sequelink://delphi:4003/[Oracle];OSUser=simha;OSPassword=*"; String oracle_username = "simha"; String oracle_password = "*"; System.out.println ("Trying connection ... "); // Make the connection. Connection con = DriverManager.getConnection (connection_url, oracle_username, oracle_password); System.out.println ("Connection succeeded"); // Next, some SQL. System.out.println ("Trying SQL ..."); // Create a Statement instance first. Statement st = con.createStatement(); // Call the executeQuery method in the instance. ResultSet rs = st.executeQuery ("select NAME from simha.CUSTOMER"); System.out.println ("SQL execution returned with:"); // Repeatedly fetch tuples from the result set. while (rs.next()) { String name = rs.getString (1); System.out.println (name); } // Close the connection. con.close(); } catch (SQLException e){ System.out.println(e); } catch (ClassNotFoundException e) { System.out.println(e); } } }