0 Replies Latest reply on Oct 27, 2008 8:45 PM by 554271

    Apps and JAVA

    554271
      Hello All,

      Does any one use java (JDBC) to connect to their DB in APPS?

      I am a newbie and I am trying to connect to my dev db using JDBC.

      1) Typically what is the common standard of storing custom java classes?

      2) My code is as shown below:
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.sql.Statement;
      import oracle.jdbc.pool.OracleDataSource;
      
      public class JDBCTest {
              public static void main(String args[]) throws SQLException, ClassNotFoundException {
              //      Class.forName("oracle.jdbc.OracleDriver");
      
                     // String dbString = "jdbc:oracle:thin:@<host IP addr>:1521:<SID>";
                      //String username = "<username>";
                     // String password = "<password>";
      
                     // DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                      OracleDataSource ods = new OracleDataSource();
                      String url = "jdbc:oracle:thin:@//<host IP addr>:1521/<SID>";
                      ods.setURL(url);
                      ods.setUser("<user name>");
                      ods.setPassword("<password>");
                      Connection conn = ods.getConnection();
      
                      //Connection connection = DriverManager.getConnection(dbString, username, password);
      
                      Statement statement = conn.createStatement();
      
                      ResultSet rs = statement.executeQuery("select 'hi' as my_column from dual");
      
                      while(rs.next())
                              System.out.println(rs.getString("MY_COLUMN"));
      
                      rs.close();
                      statement.close();
             }
      }
      Following other threads in the java forum, I tried with Class.forName, DriverManager and OracleDataSource

      I am consistently getting the same error as below:
      Exception in thread "main" java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869824)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
      at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3664)
      at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:353)
      at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:371)
      at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:551)
      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:351)
      at java.sql.DriverManager.getConnection(DriverManager.java:559)
      at java.sql.DriverManager.getConnection(DriverManager.java:189)
      at JDBCTest.main(JDBCTest.java:15)

      Some more info:
      We use AIX (don't know the version), apps11i and trying to connect to a 10g db.


      Can any one help me learn why the error is coming up?

      Please help.

      Thanks,
      Chiru

      Edited by: Megastar_Chiru on Oct 27, 2008 4:29 PM

      Edited by: Megastar_Chiru on Oct 27, 2008 4:45 PM