DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: how to call the java code form oracle database.

Hybrid View

  1. #1
    Join Date
    May 2008
    Posts
    1

    Thumbs up how to call the java code form oracle database.

    hi,

    i want to transfer the oracle data to sqlserver through jdbc.

    in my java code i have the connection string for sql server , i want to call this java code from oracle procedure.


    steps that i followed is!


    CREATE OR REPLACE PROCEDURE SQLSERVER_JDBCTEST (c1 Number)
    AS LANGUAGE JAVA
    NAME 'SqlTransfer.transferTest(int)';


    this is the oracle procedure . form this i am calling the java pgm


    my java code is


    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;

    public class SqlTransfer

    {

    public static void transferTest(int empNo) {
    try
    {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    Connection conn = DriverManager.getConnection(
    "jdbc:sqlserver://wks531\\bsl:1421;DatabaseName=datamask",
    "sa", "welcome");
    String sql = "UPDATE t1 SET empno = ? ";
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setInt(1, empNo);
    pstmt.executeUpdate();
    pstmt.close();
    conn.close();
    System.out.println("Executed successfulllllll ");
    } catch (Exception e) {
    e.printStackTrace();
    // throw e;
    }
    }

    public static void main(String a[]) {
    SqlTransfer.transferTest(33);
    }


    }


    i placed this code under $oracle\ora92\jdk\bin;

    and i used loadjava to compile the java code to create a object in oracle.

    but running the oracle procedure it give error like NOCLASSDEFFOUND error.

    i placed the jar file for sql driver in $oracle\ora92\jdbc\lib path.

    and i set the classpath too.

    i want to know where i need to put the sqlserver jar files in oracle data base..?

    if any one knows this issue please address it...

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Firstly I don't know the answer to your question.

    Secondly I would never face such an issue because of depending on the SQL Server version I would move the data pulling it from the SQL Server side resorting to either DTS or SSIS.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width