0 Replies Latest reply: Jun 20, 2012 5:05 AM by 944782 RSS

    starting logminer from java

    944782
      I want to start logminer tool from java

      To start logminer tool the first step is

      alter system set utl_file_dir='C:\oracle\product\10.2.0\logminer_dir' scope=spfile;
      shutdown immediate
      startup

      I am working on eclipse
      The alter command is executed, but to startup and shutdown immediate, I am trying to use the below program. I getting the following error in eclipse

      "Exception in thread "main" java.lang.Error: Unresolved compilation problems:
           DatabaseStartupMode cannot be resolved or is not a field
           DatabaseShutdownMode cannot be resolved or is not a field
           DatabaseShutdownMode cannot be resolved or is not a field

           at DBStartup1.main(DBStartup1.java:35)"

      How to resolve it?????

      import java.sql.*;
      import java.util.Properties;
      import oracle.jdbc.OracleConnection;
      import oracle.jdbc.pool.OracleDataSource;

      /**
      * To logon as sysdba, you need to create a password file for user "sys":
      * orapwd file=C:\oracle\product\10.2.0\db_1\dbs\orapw entries=5
      * and add the following setting in init.ora:
      * REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
      * then restart the database.
      */
      public class DBStartup1
      {
      static final String DB_URL = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XYZ.com)(PORT=1521))"
      + "(CONNECT_DATA=(SERVICE_NAME=rdbms.devplmt.XYZ.com)))";

      public static void main(String[] argv) throws Exception
      {
      // Starting up the database:
      OracleDataSource ds = new OracleDataSource();
      Properties prop = new Properties();
      prop.setProperty("user","system");
      prop.setProperty("password","oracle");
      prop.setProperty("internal_logon","sysdba");
      prop.setProperty("prelim_auth","true");
      ds.setConnectionProperties(prop);
      ds.setURL(DB_URL);



      OracleConnection conn = (OracleConnection)ds.getConnection();
      //OracleConnection.getMode();
      conn.startup (OracleConnection.DatabaseStartupMode.NO_RESTRICTION);
      conn.close();

      // Mounting and opening the database
      OracleDataSource ds1 = new OracleDataSource();
      Properties prop1 = new Properties();
      prop1.setProperty("user","sys");
      prop1.setProperty("password","manager");
      prop1.setProperty("internal_logon","sysdba");
      ds1.setConnectionProperties(prop1);
      ds1.setURL(DB_URL);
      OracleConnection conn1 = (OracleConnection)ds1.getConnection();
      Statement stmt = conn1.createStatement();
      stmt.executeUpdate("ALTER DATABASE MOUNT");
      stmt.executeUpdate("ALTER DATABASE OPEN");
      stmt.close();
      conn1.close();

      // Shutting down the database
      OracleDataSource ds2 = new OracleDataSource();
      Properties prop2 = new Properties();
      prop.setProperty("user","sys");
      prop.setProperty("password","manager");
      prop.setProperty("internal_logon","sysdba");
      ds2.setConnectionProperties(prop);
      ds2.setURL(DB_URL);
      OracleConnection conn2 = (OracleConnection)ds2.getConnection();
      conn2.shutdown(OracleConnection.DatabaseShutdownMode.IMMEDIATE);
      Statement stmt1 = conn2.createStatement();
      stmt1.executeUpdate("ALTER DATABASE CLOSE NORMAL");
      stmt1.executeUpdate("ALTER DATABASE DISMOUNT");
      stmt1.close();
      conn2.shutdown(OracleConnection.DatabaseShutdownMode.FINAL);
      conn2.close();
      }
      }