当前位置: 技术问答>java相关
看看这个问题啊,还没解决。servlet使用存储过程问题,另一页给分!
来源: 互联网 发布时间:2015-02-14
本文导语: 看看,明白的请回答,多谢! http://www.csdn.net/expert/topic/341/341060.shtm | 参考。 Stored procedure with Input/Output parms and a ResultSet Thanks to T. Guirado for the tips. public static int storedProcWithResultSet...
看看,明白的请回答,多谢!
http://www.csdn.net/expert/topic/341/341060.shtm
http://www.csdn.net/expert/topic/341/341060.shtm
|
参考。
Stored procedure with Input/Output parms and a ResultSet
Thanks to T. Guirado for the tips. public static int storedProcWithResultSet (String parms) throws Exception
// Stored procedure to be called.
CallableStatement cs = conn.prepareCall
("{? = call mypackage.p_astoreproc (?,?,?,?,?,?,?)}");
// register input parameters
cs.registerOutParameter(1, java.sql.Types.INTEGER); // return code
cs.setString(2, "");
cs.setString(3, "");
cs.setString(4, parms);
// regsiter ouput parameters
cs.registerOutParameter(5, java.sql.Types.CHAR);
cs.registerOutParameter(6, java.sql.Types.CHAR);
cs.registerOutParameter(7, java.sql.Types.CHAR);
// Procedure execution
ResultSet rs = cs.executeQuery();
// Note that you need to retrieve the ResultSet _before_ retrieving
// OUTPUT parameters.
if ( rs == null)
System.out.println( "No resultSet!");
else {
// To retrieve columns info.
ResultSetMetaData rsmd = rs.getMetaData();
int nbCol = rsmd.getColumnCount();
int i = 0;
int j = 1;
Vector vResSet = new Vector();
while (rs.next ()) {
System.out.println( "Record " + (i+1));
// putting the ResultSet columns in a vector
for ( j = 1; j
Stored procedure with Input/Output parms and a ResultSet
Thanks to T. Guirado for the tips. public static int storedProcWithResultSet (String parms) throws Exception
// Stored procedure to be called.
CallableStatement cs = conn.prepareCall
("{? = call mypackage.p_astoreproc (?,?,?,?,?,?,?)}");
// register input parameters
cs.registerOutParameter(1, java.sql.Types.INTEGER); // return code
cs.setString(2, "");
cs.setString(3, "");
cs.setString(4, parms);
// regsiter ouput parameters
cs.registerOutParameter(5, java.sql.Types.CHAR);
cs.registerOutParameter(6, java.sql.Types.CHAR);
cs.registerOutParameter(7, java.sql.Types.CHAR);
// Procedure execution
ResultSet rs = cs.executeQuery();
// Note that you need to retrieve the ResultSet _before_ retrieving
// OUTPUT parameters.
if ( rs == null)
System.out.println( "No resultSet!");
else {
// To retrieve columns info.
ResultSetMetaData rsmd = rs.getMetaData();
int nbCol = rsmd.getColumnCount();
int i = 0;
int j = 1;
Vector vResSet = new Vector();
while (rs.next ()) {
System.out.println( "Record " + (i+1));
// putting the ResultSet columns in a vector
for ( j = 1; j