I am working with preparedStmts and resultSets for the first time on an assignment, when I run this program, it runs to completion, but it does not add anything to the sql table. We must use those two together and I have scoured the internet to try to figure out how to get this to work, but am still having problems. Any help would be great, thanks.
<%
int result = 0;
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = JdbcManager.getConnection();
String sqlcmd = "select * from APP.STOCK_TBL";
stmt = conn.prepareStatement(sqlcmd, rs.TYPE_SCROLL_INSENSITIVE, rs.CONCUR_UPDATABLE, rs.HOLD_CURSORS_OVER_COMMIT);
String symbol = request.getParameter("SYMBOL");
String name = request.getParameter("NAME");
rs = stmt.executeQuery();
while(rs.next()){
if(rs.getString("SYMBOL").equals( rs.getString(1))){
rs.updateString("SYMBOL", rs.getString("SYMBOL"));
rs.updateString("NAME", rs.getString("NAME"));
rs.updateRow();
}
if(!(rs.getString("SYMBOL").equals(rs.getString(1)))){
if(rs.isAfterLast()){
rs.moveToInsertRow();
rs.updateString(1, rs.getString("SYMBOL"));
rs.updateString(2, rs.getString("NAME"));
rs.insertRow();
}
}
}
%>
Edit* Sorry forgot to explain issue, when I run this program, it runs to completion, but it does not add anything to the sql table. Edit** Updated code