import java.io.*;
import java.util.*;
import java.sql.*; 


public class dbtestapp 
{

    public static void main(String args[]) throws IOException, ClassNotFoundException
    {
                // components out of which to build the connect string
                String driver   = "jdbc:oracle:thin";
                String user     = "sa";
                String password = "pass";
                String host     = "myhost";
                String port     = "1521";
                String sid      = "oTest";

                // build the connectstring out of the listed components
                String connectstring = driver + ":" + user + "/" + password + "@" + host + ":" + port + ":" + sid;
        	
                try 
                {
                        // load the JDBC driver
                        Class.forName("oracle.jdbc.driver.OracleDriver");
                        } catch (Exception e) {
                        System.err.println("Unable to load JDBC driver");
                        System.err.println("Exception: " + e.getMessage());
                }

                try 
                {
                        // connect to the database
                        Connection con = DriverManager.getConnection(connectstring);

                        System.out.println("<HTML><HEAD></HEAD><BODY><H1>");

                        String myQuery = "select derivation " +
                                                         "from   mytable " +
                                                         "where  id = 118368 ";

                        // build the statement
                        Statement getDerivation = con.createStatement();

                        // run the query
                        ResultSet rs = getDerivation.executeQuery(myQuery);
                	
                        // read the results & print them out
                        while (rs.next()) {
                                String derivation = rs.getString("DERIVATION");
                                System.out.println("DERIVATION is " + derivation);
                        }

                        // print the final line of HTML
                        System.out.println("</H1></BODY></HTML>");
                        System.out.close();

                        } catch (SQLException e) {
                        e.printStackTrace();
                        System.err.println("Unable to read derivation: " + e.getMessage());
                }
        }

}

