1

This is my oracle procedure :

FUNCTION JavaHefExtract_runSingle (
    p_company_cd        varchar2,
    p_srcConnString     varchar2,
    p_destConnString    varchar2,
    p_mode              number,
    p_period            number
    ) return varchar2
IS
LANGUAGE JAVA
NAME 'HefExtract.DoIt(java.lang.String, java.lang.String, java.lang.String, int, int ) return java.lang.String';

And this is my java function:

import com.microsoft.sqlserver.jdbc.*;
import java.math.BigInteger;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Enumeration;
import oracle.jdbc.*;
import java.io.*;

public class HefExtract
{

 public static String DoIt(String orgName, String oracleConnstring, String sqlConnstring, int typ, int iPeriod )
    {
        String errMsg = null;
        Connection sqlConn;
        Connection oracleConn;
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Class.forName("oracle.jdbc.OracleDriver");
            if (oracleConnstring != null)
                oracleConn = DriverManager.getConnection(oracleConnstring);
            else
                oracleConn = new OracleDriver().defaultConnection();
            sqlConn = DriverManager.getConnection(sqlConnstring);
        } catch (Throwable e1) {
            CharArrayWriter byteSink = new CharArrayWriter();
            e1.printStackTrace(new PrintWriter(byteSink));
            return byteSink.toString();
        }
        return errMsg;
}
}

When I call the oracle procedure in PL/SQL block this error is returned:

java.lang.ClassNotFoundException: com/microsoft/sqlserver/jdbc/SQLServerDriver at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java) at HefExtract.DoIt(HEFEXTRACT:415)

What may be the reason behind this error?

2
  • 2
    com.microsoft.sqlserver.jdbc.SQLServerDriver is Microsft SQL Driver not oracle's driver. You are getting this error because you dont have microsft sql driver on your classpath Commented Aug 5, 2012 at 4:55
  • Did you register the Java class in the Oracle server? And if you are not connecting to SQL Server, why are you loading its driver? Commented Aug 5, 2012 at 8:05

2 Answers 2

1

As far as I can tell, there's no need to use the Microsoft SQL Server driver in your case. Just remove everything that has to do with the Microsoft driver, i.e. delete these lines:

import com.microsoft.sqlserver.jdbc.*;

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Sign up to request clarification or add additional context in comments.

Comments

0

Go through this Wiki Article on how to set the classpath which has lot of examples. http://en.wikipedia.org/wiki/Classpath_(Java)

If you are using Eclipse Select the Project -> Properties -> Project Build Path -> Java Libraries locate the jar file and select it

If you are using netbeans Select the Project -> Properties -> Libraries -> Compile locate the jar and select it

This post also may help to resolve your problem

1 Comment

It's a server side Java function. Those are not influenced by the NetBeans or Eclipse classpath

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.