//********************************************************************* // // Copyright (c) 2004-2008 by Teradata Corporation // All Rights Reserved // //********************************************************************* // // File: sample1.java // Purpose: This sample application will: // - log on // - log off // //********************************************************************* import java.sql.*; public class sample1 { public static void main (String [] args) throws ClassNotFoundException { // Teradata Type 4 JDBC Driver String url = "jdbc:teradata://whomooz/TMODE=ANSI,CHARSET=UTF8"; try { // Load the Teradata Driver Class.forName ("com.teradata.jdbc.TeraDriver"); // Connect to the Teradata database specified in the URL // and submit userid and password. System.out.println("Connecting to " + url); Connection con = DriverManager.getConnection (url, "guest", "please"); System.out.println("Established successful connection"); con.close(); System.out.println("Disconnected"); } catch (SQLException ex) { // A SQLException was generated. Catch it and display // the error information. // Note that there could be multiple error objects chained // together. System.out.println(); System.out.println("*** SQLException caught ***"); while (ex != null) { System.out.println(" Error code: " + ex.getErrorCode()); System.out.println(" SQL State: " + ex.getSQLState()); System.out.println(" Message: " + ex.getMessage()); ex.printStackTrace(); System.out.println(); ex = ex.getNextException(); } throw new IllegalStateException ("Sample failed.") ; } } }