-
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|