

package test;

import java.io.PrintStream;
import java.sql.*;

public class ConnOracle
{

    String serverName;
    String sDBDriver;
    String sConnStr;
    Connection connect;
    ResultSet rs;

    public ConnOracle()
    {
        serverName = "localhost";
        sDBDriver = "oracle.jdbc.driver.OracleDriver";
        sConnStr = "jdbc:oracle:thin:@" + serverName + ":1521:ora9";
        connect = null;
        rs = null;
        try
        {
            Class.forName(sDBDriver);
        }
        catch(ClassNotFoundException classnotfoundexception)
        {
            System.err.println(classnotfoundexception.getMessage());
        }
    }

    public ResultSet executeQuery(String s)
    {
        try
        {
            connect = DriverManager.getConnection(sConnStr, "scott", "tiger");
            Statement statement = connect.createStatement(1004, 1007);
            rs = statement.executeQuery(s);
        }
        catch(SQLException sqlexception)
        {
            System.err.println(sqlexception.getMessage());
        }
        return rs;
    }

    public int executeUpdate(String s)
    {
        int i = 0;
        try
        {
            connect = DriverManager.getConnection(sConnStr, "scott", "tiger");
            Statement statement = connect.createStatement(1004, 1007);
            i = statement.executeUpdate(s);
        }
        catch(SQLException sqlexception)
        {
            System.err.println(sqlexception.getMessage());
        }
        return i;
    }
}
