Joined: Jun 07, 2010 Posts: 1
[Post New]posted Today 12:53:46 AM Quote Edit Help me,
AM using struts2 frame work, am sending the values to db method and i have written code, my try block executed no err msg in console, I get the msg Stored procedure exe succ, but my values are not get insert into table. In sql stored procedure 4 input params and 4 output param has been given. I get values in debug mode for the values for input params, which i get that form bean, but not for output params, here with i add my code please help me with this bug.
package db;
import java.util.List;
import java.sql.*;
import hbsbean.AddNewFieldsBean;
public class ApplicationStoredDB {
public List<AddNewFieldsBean> storeNewRecords(AddNewFieldsBean bean) {
List<AddNewFieldsBean> nbean = null;
Connection conn = null;
String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbURL = "jdbc: odbc:sqlserver";
String usernameDbConn = "root";
String passwordDbConn = "hbsroot";
try {
Class.forName(jdbcDriver).newInstance();
conn = DriverManager.getConnection(dbURL, usernameDbConn,
passwordDbConn);
} catch (Exception e) {
System.out.println("jdbc driver not found:" + dbURL);
e.printStackTrace();
}
try {
// make a callable statement for a stored procedure.
CallableStatement cstmt = conn
.prepareCall("{call proc_application_menu(?, ?, ?, ?, ?, ?, ? ,?)}");
// set the values of the stored procedure's input parameters
System.out.println("calling stored procedure . . .");
for (int i = 0; i < bean.getAppName().length; i++) {
cstmt.setString(1, bean.getAppName()[i]);
cstmt.setString(2, bean.getBasepath()[i]);
cstmt.setString(3, bean.getDesc()[i]);
cstmt.setString(4, bean.getUsername());
// output params in sql
cstmt.registerOutParameter(5, Types.INTEGER);
cstmt.registerOutParameter(6, Types.INTEGER);
cstmt.registerOutParameter(7, Types.VARCHAR);
cstmt.registerOutParameter(8, Types.VARCHAR);
cstmt.execute();
}
// now that the input parameters are set, we can proceed to execute
// the insertTheForm stored procedure
cstmt.close();
System.out.println("Stored procedure executed succesfully.....");
}
catch (SQLException e) {
System.out.println("error: " + e);
e.printStackTrace();
}
return nbean;
}
}