• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insertion Values not get stored in sql server using stored procdure in struts2

 
bugsnow nowbugs
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
}
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.

Also, please see the JavaRanch naming policy and change your display name to conform with this policy. Thanks!

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this actually a Struts 2 question, or a JDBC question? Assuming the values are getting to the action correctly, it seems more the latter, thus in the wrong forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic