Topic
14 replies Latest Post - ‏2011-06-30T12:19:17Z by Sathish804
SystemAdmin
SystemAdmin
16727 Posts
ACCEPTED ANSWER

Pinned topic How to connect Oracle data base.

‏2011-06-01T06:38:13Z |
Hi,

I am using RFT 8.1, currently we are using MSAcces database , we wants to update "Oracle database". how to use Oracle DB? if any buddies know help me to resolve this issues.

I installed Oracle 10g Express edition.

Thanks in Advance.
Updated on 2011-06-30T12:19:17Z at 2011-06-30T12:19:17Z by Sathish804
  • Sathish804
    Sathish804
    1239 Posts
    ACCEPTED ANSWER

    Re: How to connect Oracle data base.

    ‏2011-06-01T07:31:52Z  in response to SystemAdmin
    Hi Bismilla,

    You have to write Java JDBC code to connect to Oracle DB with necessary jar's files placed in Projetc Build path.Below link will help you on this.

    http://www.herongyang.com/JDBC/Oracle-JDBC-Driver-Connection-URL.html
    • SystemAdmin
      SystemAdmin
      16727 Posts
      ACCEPTED ANSWER

      Re: How to connect Oracle data base.

      ‏2011-06-01T08:57:52Z  in response to Sathish804
      Thanks for ur reply Sathish,

      I didn't place any Jar files to build path, which jar files has to place in build path.

      I am New to RFT, if u provide step by step, its more help for me.
      • Sathish804
        Sathish804
        1239 Posts
        ACCEPTED ANSWER

        Re: How to connect Oracle data base.

        ‏2011-06-01T09:12:13Z  in response to SystemAdmin
        Hi Bismilla,

        You have to create a method with below steps to connect to Oracle DB

        Class.forName("oracle.jdbc.OracleDriver") ;
              System.out.println("Oracle JDBC driver loaded ok.");
         
        //This is connection url format jdbc:oracle:thin:@<server>[:<1521>]:<database_name>
              con = DriverManager.getConnection(
                "jdbc:oracle:thin:@localhost:1521:XE");
         
        //Once after creating connection you can write statements to fetch results from tables using queries.
        


        To establish the connection you need ojdbc14.jar placed in your class path.. You can find this jar file in Oracle installation folder.

        Hope this helps you!!!
        Updated on 2014-03-25T13:25:20Z at 2014-03-25T13:25:20Z by iron-man
        • SystemAdmin
          SystemAdmin
          16727 Posts
          ACCEPTED ANSWER

          Re: How to connect Oracle data base.

          ‏2011-06-01T09:50:04Z  in response to Sathish804
          Hi Sathish,

          As per your guide, i placed the jar files in build path and connection code i applied in the scripts, but its throws the exception.

          Can u please find the doc for your reference.

          Attachments

          • SystemAdmin
            SystemAdmin
            16727 Posts
            ACCEPTED ANSWER

            Re: How to connect Oracle data base.

            ‏2011-06-01T11:08:41Z  in response to SystemAdmin
            Hi,

            Which Oracle URL has to place, its throwing bellow error, can u please help me to resolve this issue.

            exception_name = java.sql.SQLException
            exception_message = Invalid Oracle URL specified
            script_name = Script1
            script_id = Script1.java
            line_number = 42
            exception_stack = at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:538)
            at java.sql.DriverManager.getConnection(DriverManager.java:317)
            at java.sql.DriverManager.getConnection(DriverManager.java:273)
            at Script1.testMain(Script1.java:42)
            at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)
            at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
            at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
            at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
            at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
            at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
            at org.eclipse.core.launcher.Main.main(Main.java:30)
            • Sathish804
              Sathish804
              1239 Posts
              ACCEPTED ANSWER

              Re: How to connect Oracle data base.

              ‏2011-06-01T11:48:39Z  in response to SystemAdmin
              Hi Bismilla,

              In DB URL you have to replace localhost with the system ip where your oracle DB is installed and XE should be replaced with your database name. And also you have to mention user id and password for that database.
              • SystemAdmin
                SystemAdmin
                16727 Posts
                ACCEPTED ANSWER

                Re: How to connect Oracle data base.

                ‏2011-06-02T09:48:40Z  in response to Sathish804
                Thanks Sathish,

                As you said i done below like,

                public void testMain(Object[] args) throws SQLException, ClassNotFoundException
                {
                Class.forName("oracle.jdbc.OracleDriver") ;
                System.out.println("Oracle JDBC driver loaded ok.");

                //This is connection url format jdbc:oracle:thin:@<server>:<1521>:<database_name>
                Connection con = DriverManager.getConnection(
                "jdbc:oracle:thin:@http://127.0.0.1:8080/apex/f?p=4550:11:3759850024427306::NO::::10.237.7.167:Oracle Database XE");
                String DBuser = "shanavas";
                String DBpass = "Bismilla1@";
                System.out.println("Welcome to DB");

                //Once after creating connection you can write statements to fetch results from tables using queries.
                }

                While executing i got a output like:--

                Oracle JDBC driver loaded ok.
                Exception occurred during playback of script Script1 CRFCN0670E: RationalTestScriptException on line 42 of script Script1 - java.sql.SQLException: invalid arguments in call..

                Can u pls help me to connect....
                • Sathish804
                  Sathish804
                  1239 Posts
                  ACCEPTED ANSWER

                  Re: How to connect Oracle data base.

                  ‏2011-06-02T11:26:51Z  in response to SystemAdmin
                  Hi,

                  Your connection URL is wrong...

                  public void testMain(Object[] args) throws SQLException, ClassNotFoundException 
                  {
                  Class.forName("oracle.jdbc.OracleDriver") ;
                  System.out.println("Oracle JDBC driver loaded ok.");
                   
                  //This is connection url format jdbc:oracle:thin:@<server>:<1521>:<database_name>
                  Connection con = DriverManager.getConnection(
                  "jdbc:oracle:thin:@10.237.7.167:1521:Oracle Database XE");
                  String DBuser = "shanavas";
                  String DBpass = "Bismilla1@";
                  System.out.println("Welcome to DB");
                   
                  //Once after creating connection you can write statements to fetch results from tables using queries.
                  }
                  


                  Assuming 10.237.7.167 is your host ip where your oracle db is installed and Oracle Database XE is data base name.

                  Hope this helps you.
                  Updated on 2014-03-25T13:25:10Z at 2014-03-25T13:25:10Z by iron-man
                  • SystemAdmin
                    SystemAdmin
                    16727 Posts
                    ACCEPTED ANSWER

                    Re: How to connect Oracle data base.

                    ‏2011-06-03T06:00:59Z  in response to Sathish804
                    Hi Sathish,

                    Thank u very much, i corrected my connection url, but after execution its throwing bellow error

                    public void testMain(Object[] args) throws SQLException, ClassNotFoundException
                    {
                    Class.forName("oracle.jdbc.OracleDriver") ;
                    System.out.println("Oracle JDBC driver loaded ok.");
                    Connection con;

                    //This is connection url format jdbc:oracle:thin:@<server>:<1521>:<database_name>
                    con = DriverManager.getConnection(
                    "jdbc:oracle:thin:@127.0.0.1:1521:Oracle Database XE");
                    String DBuser = "shanavas";
                    String DBpass = "Bismilla1@";
                    System.out.println("Welcome to DB");
                    }

                    Output:--

                    Oracle JDBC driver loaded ok.
                    Exception occurred during playback of script CRFCN0670E: RationalTestScriptException on line 50 of script Script1 - java.sql.SQLException: invalid arguments in call..

                    Can u please help me to to get the connection.
                    • Sathish804
                      Sathish804
                      1239 Posts
                      ACCEPTED ANSWER

                      Re: How to connect Oracle data base.

                      ‏2011-06-03T06:10:12Z  in response to SystemAdmin
                      Hi,

                      You are not passing the user id and password to the connection.

                      Try below peice of code.

                      Connection connection = null;
                      try {
                          // Load the JDBC driver
                          String driverName = "oracle.jdbc.driver.OracleDriver";
                          Class.forName(driverName);
                       
                          // Create a connection to the database
                          String serverName = "127.0.0.1";
                          String portNumber = "1521";
                          String sid = "Oracle Database XE";
                          String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
                          String username = "username";
                          String password = "password";
                          connection = DriverManager.getConnection(url, username, password);
                      } catch (ClassNotFoundException e) {
                          // Could not find the database driver
                      } catch (SQLException e) {
                          // Could not connect to the database
                      }
                      


                      Hope this helps you!!
                      Updated on 2014-03-25T13:25:02Z at 2014-03-25T13:25:02Z by iron-man
                      • SystemAdmin
                        SystemAdmin
                        16727 Posts
                        ACCEPTED ANSWER

                        Re: How to connect Oracle data base.

                        ‏2011-06-03T10:12:51Z  in response to Sathish804
                        Hi Sathish,

                        Great help u done for me, since am beginner for RFT, i applied what u suggest me the code, while executing log files are showing pass.
                        Thanks a lot.......
  • SystemAdmin
    SystemAdmin
    16727 Posts
    ACCEPTED ANSWER

    Re: How to connect Oracle data base.

    ‏2011-06-30T11:39:47Z  in response to SystemAdmin
    Hi all

    I am using RFT version 8.1. I am unable to connect to oracle database despite using the correct connection string . Please find the Input and Output attached. I have used all 3 combination of driver names oracle.jdbc.driver.OracleDriver,Oracle.jdbc.driver.OracleDriver,oracle.driver.OracleDriver.

    Please help me out.
    • Sathish804
      Sathish804
      1239 Posts
      ACCEPTED ANSWER

      Re: How to connect Oracle data base.

      ‏2011-06-30T12:19:17Z  in response to SystemAdmin
      Hi,

      As per my guess , you have not placed required JDBC jar files in Class path of your project. Can you make sure that you have placed required jar files(ojdbc14.jar etc) in class path of your project.

      Hope this helps you!!