package examples.jdbc.informix4;

import java.sql.*;
import java.util.Properties;

/**
 * This simple example shows the alternatives for making a
 * JDBC connection to an Informix instance. 
 *<h3>To set up this example:</h3>
 *<ol>
 *<li>Set up your development shell as described in <a
 *href=Package-examples.jdbc.informix4.html>Package examples.jdbc.informix4</a>.
 *<p>
 *<li> Change connection parameters to correspond to your Informix
 *Dynamic Server configuration.  If you need more help, check the section on
 *connecting to a database in the Developers Guide, <a
 *href=../../../classdocs/API_jinf4.html>Using WebLogic jDriver for Informix</a>.
 *
 *<p>
 *
 *<li>Compile this example by executing the following command in your development shell:
 *
 *<p>
 *
 *<font face="Courier New"><b>$ javac -d c:/weblogic/informix4/classes login.java</b></font>
 *<p>	
 *
 *<li>Run this example by executing the following command in your development shell:
 *
 *<p>
 *
 *<font face="Courier New"><b>$ java examples.jdbc.informix4.login</b></font>
 *
 *</ol>
 *
 *
 * @author Copyright (c) 1996-2000 by BEA Systems, Inc.  All Rights Reserved.
 */
public class login {

  public static void main(String argv[])
       throws Exception
  {
    
    // You can connect to a database with JDBC in various ways.
    
    Properties props = new Properties();
    props.put("user",     "informix");
    props.put("password", "secret");
    props.put("server",   "myDBHost"); // hostname on which Informix server runs
    props.put("port",     "1493");       // port on which Informix server listens
    props.put("db",       "myDB");  // name of database on Informix server
    
    Driver myDriver= (Driver)
    Class.forName("weblogic.jdbc.informix4.Driver").newInstance();
    Connection conn1 = myDriver.connect("jdbc:weblogic:informix4", props);
    conn1.close();
    System.out.println("Logged in successfully with style #1.");
    
    // The simplest thing to do is to embed the connection parameters in the URL.
    // Then use a Properties object to pass in the username and password.
    Properties props2 = new Properties();
    props2.put("user",     "informix");
    props2.put("password", "secret");

    Connection conn2 = myDriver.connect("jdbc:weblogic:informix4:myDB@myDBHost:1493", props2 );
    conn2.close();
    
    System.out.println("Logged in successfully with style #2.");
  }
}










