Hello all,
I'm a JSP newbie, so treat with care ...
First things first, my thanks to the original authors of the articles found at
http://www.enterprisedt.com/publicat...esult_set.html and
and
http://www.macromedia.com/devnet/ser...on_of_jsp.html
Very useful articles for someone like me trying to learn the art of JSP.
Now the question, based upon the examples at the above sites, I decided to test out calling an Oracle Stored Procedure through a JSP page via a JavaBean, but I jst can't get it to work :(
1/ My JavaBean
import java.io.*;
import java.sql.*;
import java.util.*;
import oracle.jdbc.driver.*;
public class MrBean implements Serializable {
private float price = 0;
public MrBean () {}
public float getPrice() { return price;}
public void setPrice(float sz) {price = sz;}
public ResultSet executeQuery() {
Connection conn = null;
CallableStatement stmt = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection ("jdbc:oracle:thin:@172.25.24.25:1521:EINSTEIN",US ERNAME,PASSWORD);
String query = "begin ? := sp_get_stocks(?); end;";
stmt = conn.prepareCall(query);
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.setFloat(2,price);
stmt.execute();
rs = (ResultSet)stmt.getObject(1);
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe.getMessage());
}
catch (Exception e) {
System.err.println(e.getMessage());
}
finally {
try {
if ( conn != null ) {
// Close the connection no matter what
conn.close();
}
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
} // end of finally block
return rs; // the ResultSet is sent back to the JSP page context.
} // end of executeQuery
} //EOF