2 Replies Latest reply on Jan 9, 2008 5:57 PM by 592777

    Problem Using Java Store Procedure (java class) to connect to sybase

    592777
      Hi, I'm trying to use a java class to obtain some data from another databse (SYBASE) in another server.. here are the code

      package pkg;

      import com.sybase.jdbcx.SybDriver;
      import java.sql.Connection;
      import java.sql.Driver;
      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.sql.Statement;


      public class clsTest
      {
      public clsTest()
      {
      }
      public static void main(String[] args)
      {
      testConn("");
      }

      private static void testConn()
      {
      Connection _con= null;
      String host = "XXX";
      String port= "XXX";
      String url = host + ":" + port;
      Statement _stmt= null;
      int timeout = 10;
      boolean needsReconnect = true;
      SybDriver sybDriver = null;
      try
      {
      Class c = Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
      sybDriver = (SybDriver) c.newInstance();
      DriverManager.registerDriver((Driver) sybDriver);
      }
      catch (Exception e)
      {

      System.err.print("Unable to load the Sybase JDBC driver. "
      + e.toString());
      e.printStackTrace(System.out);
      }
      if (needsReconnect)

      try
      {

      if (_con != null)
      {
      _con.close();
      }
      url="jdbc:sybase:Tds:BDSERVER:PORT/BD";
      System.err.println("Trying to connect to: " + url);
      DriverManager.setLoginTimeout(timeout);
      con = DriverManager.getConnection(url,"usrquery","mundial");
      _stmt = _con.createStatement();

      boolean results = _stmt.execute("select count(*) from TABLA");
      if (results)
      {
      ResultSet rs= _stmt.getResultSet();
      rs.next();
      System.err.println(rs.getString(1));
      }
      _con.close();
      }
      catch (SQLException sqle)
      {
      System.err.println(sqle.toString() + " Restart connection.");
      return;
      }
      catch (Exception e)
      {
      e.printStackTrace();
      System.err.println("Unexpected Exception: " + e.toString());
      return;
      }
      }
      }
      }

      When I run the proyect using the IDE JDeveloper I have no problem, but when I make de use loadjava I receive these error message


      creating : resource META-INF/MANIFEST.MF
      loading : resource META-INF/MANIFEST.MF
      Error while creating resource META-INF/MANIFEST.MF
      ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler

      creating : class pkg/clsTest
      loading : class pkg/clsTest
      creating : resource jconn3.jar
      loading : resource jconn3.jar
      Error while creating resource jconn3.jar
      ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler

      granting : execute on class pkg/clsTest to public
      Error while computing shortname of pkg/clsSybaseLAE
      ORA-06550: line 1, column 13:
      PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
      ORA-06550: line 1, column 7:
      PL/SQL: Statement ignored

      resolving: class pkg/clsTest
      errors : class pkg/clsTest
      ORA-29521: referenced name java/lang/StringBuffer could not be found
      ORA-29521: referenced name java/lang/Class could not be found
      ORA-29521: referenced name com/sybase/jdbcx/SybDriver could not be found
      ORA-29521: referenced name java/sql/Driver could not be found
      ORA-29521: referenced name java/sql/DriverManager could not be found
      ORA-29521: referenced name java/lang/System could not be found
      ORA-29521: referenced name java/lang/Exception could not be found
      ORA-29521: referenced name java/io/PrintStream could not be found
      ORA-29521: referenced name java/sql/Connection could not be found
      ORA-29521: referenced name java/sql/Statement could not be found
      ORA-29521: referenced name java/sql/ResultSet could not be found
      ORA-29521: referenced name java/sql/SQLException could not be found
      ORA-29521: referenced name java/lang/Object could not be found
      ORA-29521: referenced name java/lang/String could not be found
      synonym : pkg/clsTest
      The following operations failed
      resource META-INF/MANIFEST.MF: creation
      class pkg/clsTest: resolution
      resource jconn3.jar: creation
      exiting : Failures occurred during processing

      Please some one help me!.. Thank's a lot
        • 1. Re: Problem Using Java Store Procedure (java class) to connect to sybase
          Avi Abrami
          Carlos,
          I'm only guessing, but it looks like maybe java isn't correctly installed in your database.
          If java is installed then the DBMS_JAVA package will exist.
          To check whether DBMS_JAVA exists, you can simply connect to the database via SQL*Plus and type the command:
          desc DBMS_JAVA
          Good Luck,
          Avi.
          • 2. Re: Problem Using Java Store Procedure (java class) to connect to sybase
            592777
            Thanks, you was right, but I have another problem

            The following operations failed
            class cl/bcch/clsSyBase: resolution
            source cl/bcch/clsSyBase: creation (createFailed)
            oracle.aurora.server.tools.loadjava.ToolsException: Failures occurred during processing
                 at oracle.aurora.server.tools.loadjava.LoadJava.process(LoadJava.java:1057)
                 at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:124)
                 at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:53)
                 at oracle.jdevimpl.deploy.OracleDeployer.deploy(OracleDeployer.java:98)
                 at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:503)
                 at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:381)
                 at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:300)
                 at oracle.jdevimpl.deploy.StoredProcProfileDt$Action$1.run(StoredProcProfileDt.java:598)
            #### Export incomplete. #### 09-01-2008 02:28:39 PM
            *** Note ***
            One possibility for the database export failure is that the target Database may not support JDK version 1.4. Updating your Project Properties compiler Source & Target to an earlier release could fix this problem.
            ************