Image

Callable Statements

Edit: This seems to be working now...when I executed the query, I should have placed it in the ResultSet. Thanks!!

Can someone tell me why I am getting the error java.sql.SQLException: [IBM][SQLServer JDBC Driver]Invalid parameter binding(s).? I am all confused with registerOutParameter.


public SegmentBean[] getSegment() throws SQLException {

Connection conn = null;
ResultSet rs = null;
try {
conn = pool.getConnection();

segments = conn.prepareCall("{call sp_Getsegments[(?)]}");
segments.registerOutParameter(1, java.sql.Types.CHAR);

Collection segment = new ArrayList();

segments.setString(1, " ");
segments.registerOutParameter(1, java.sql.Types.CHAR);

segments.executeQuery();
SegmentBean segBean;
while (rs.next())
{
segment.add(makeSegmentBean(rs));
}

return (SegmentBean[]) segment.toArray(new SegmentBean[0]);

} catch (SQLException sqle) {

throw sqle;
} finally {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
System.out.println("Close Resultset Exception: " + e.getMessage());
}
}

if (segments != null) {
try {
segments.close();
} catch (Exception e) {
System.out.println("Close Statement Exception: getAllSegStmt" + e.getMessage());
}
}

if (conn != null) {
conn.close();
}
}
}