How can I pass Object to SQL server stored procedure using java code? -
public class student{ protected string name; protected string marks; public student(string name, string marks){ this.name=name; this.marks=marks; } //getters , setters above }
from other class tried below
student[] std=new student[2]; std[0]=new student("user1","80"); std[1]=new student("user2","70"); string section = "a"; connection conn=drivermanager.getconnection("jdbc:sqlserver://...."); callablestatement stmt= conn.preparecall("{call userdatils(?,?,?)}"); stmt.setstring(2, section); //stmt.setarray(3, std); stmt.setobject(3, std); stmt.registeroutparameter(1, java.sql,types.varchar); stmt.execute();
here issue below 2 lines.
//stmt.setarray(3, std); stmt.setobject(3, std);
when run above setobject saying, "the conversion unknown unknown unsupported.
i not able set value.
please me pass above student info stored procedure.
thank you.
first, try use std [0] instead of std.
Comments
Post a Comment