Home » Developer & Programmer » JDeveloper, Java & XML » problem on java stored procedures
problem on java stored procedures [message #366768] Mon, 11 December 2000 00:39 Go to next message
Messages: 3
Registered: December 2000
Junior Member
I have a problem. It will be of great help to me if you can suggest any solution for my problem.

I have written a java program which has a insert statement into a table in the database, compiled it and executed it. I got the intended result ie I am able to insert a row into the table.

The same java code( I have removed the main part), I have compiled it and loaded the class into the database with javaload command. In the datbase I am able to see that the javaclass is in valid state. I have written a stored procedure which is wrapper for the above java class( which is having a method).
When I execute the stored procedure , It says that the stored procedure is successfully executed but it is not inserting a row into the database table.

I am sending code for clarity purpose

java code

import java.sql.*;
import java.io.*;
public class DBTrigger {
public static void logSal (int empID, float oldSal, float newSal)
throws Exception {
Connection con=DriverManager.getConnection("jdbc:odbc:sree","sree","sree");
String sql = "INSERT INTO sal_audit VALUES (?, ?, ?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setInt(1, empID);
pstmt.setFloat(2, oldSal);
pstmt.setFloat(3, newSal);
catch(Exception m)
{ m.printStackTrace();}
/* public static void main(String args[[]])
DBTrigger dbt = new DBTrigger();
}catch(Exception e)
{ e.printStackTrace();}
} */

stored procedure

emp_id NUMBER, old_sal NUMBER, new_sal NUMBER)
'Sree.logSal(int, float, float)';

Thanks & Regards
Re: problem on java stored procedures [message #366769 is a reply to message #366768] Mon, 11 December 2000 10:25 Go to previous messageGo to next message
T. Nguyen
Messages: 5
Registered: November 2000
Junior Member
You may need to do a "commit". Try it.

T. Nguyen
Re: problem on java stored procedures [message #366781 is a reply to message #366768] Wed, 27 December 2000 22:27 Go to previous message
Messages: 9
Registered: March 2000
Junior Member
Hi Sree,
You need to put a "commit; " statement after inserting. that is theproblem.
One more thing is, could yopu please tell me how to load a class file into databas and call it in your javacode?
Please tell me the procedure. I am doing a Live GE project I need that procedure. First of all what is thestructure of the database table to inssert a java class and procedure to call it form other hjava program. is this possible using jdk1.1.6 because we have to use jdk1.1.6 with jdbc1.0 . Please send me the procedure.

Thanks & Regards,
Previous Topic: What is the way to use the Loadjava command?
Next Topic: Create Java Class
Goto Forum:

Current Time: Fri Dec 02 18:23:39 CST 2022