
/*
 * This sample can be used to check the JDBC installation.
 * Just run it and provide the connect information.  It will select
 * "Hello World" from the database.
 */

// You need to import the java.sql package to use JDBC
import java.sql.*;

// We import java.io to be able to read from the command line
import java.io.*;

import oracle.jdbc.*;

class JdbcCheckup
{
    public static void main(String args[])
        throws SQLException, IOException
    {
        // Load the Oracle JDBC driver
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

        // Prompt the user for connect information
        System.out.print("Connecting to the database...");
        System.out.flush();

        System.out.println("Connecting...");
      Connection conn = DriverManager.getConnection
          ("jdbc:oracle:thin:@matrix:1521:databasename","sqlpluslogin", "sqlpluspassword");

      System.out.println("connected.");

      // Create a statement
      Statement stmt = conn.createStatement();

      System.out.println("After create");

      // Do the SQL "Hello World" thing
      String qq = "create table titit (NAME VARCHAR2(80), ID INTEGER, ADDR CHAR(16))";


      System.out.println("after String");

      stmt.executeUpdate(qq);

      System.out.println(qq);

      //      while (rset.next())
      //  System.out.println(rset.getString(1));

      // close the result set, the statement and connect

      System.out.println("after while");

      // rset.close();

      System.out.println("after rset close");

      stmt.close();

      System.out.println("after stmt close");

      conn.close();
      System.out.println("Your JDBC installation is correct.");
  

   }

    // Utility function to read a line from standard input
    static String readEntry(String prompt)
    {
      try
          {
              StringBuffer buffer = new StringBuffer();
              System.out.print(prompt);
              System.out.flush();
              int c = System.in.read();
              while (c != '\n' && c != -1)
                  {
                      buffer.append((char)c);
                      c = System.in.read();
                  }
              return buffer.toString().trim();
          }
      catch(IOException e)
          {
              return "";
          }
    }
}

