Advertisement

Udemy WW Udemy WW

Friday 2 December 2011

Calling SQL Function Through JAVA program

//calling function
import java.sql.*;
class MyFunction
{
public static void main(String arg[])
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection c=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","student","student");
CallableStatement cs=c.prepareCall("{?=call SUM1(?,?)}");
cs.setInt(2,10);
cs.setInt(3,40);
cs.registerOutParameter(1,Types.INTEGER);
cs.execute();
int a=cs.getInt(1);
System.out.println("value="+a);



}
catch(Exception e)
{
System.out.println(e);
}
}
}

No comments:

Post a Comment

Advertisement

Udemy WW