updating saving table and shows the updated rows- its urgent

wht i m trying is i m using three text boxes in my module

textbox1- from account ( account no from where amount is to be transfered)

textbox2- to accont(account no in which amount is to be added)

textbox3- the amount (which is being transfered)

user enters values in all the boxes:- and on submit btom action i m calling a jsp file which is updating table named saving in database , i m using following code:-

con.setAutoCommit(false);

String updateSaving ="update saving set balance = balance - amount1 where saving.account_no = '" + one +"'";

st.executeUpdate(updateSaving);

con.commit();

con.setAutoCommit(true);

}

ResultSet rs1 = st.executeQuery("select * from saving where saving.account_no = '" + session.getAttribute( "acc" ) + "'");

while (rs1.next()) {%>

<tr>

<td valign="top" height="43"><%=rs1.getString(1) %></td>

<td valign="top"> <%=rs1.getString(2) %></td>............

my problem is i m not getting any output. i m nt understanding where is the problem? can anybody help me?

please its really very urgent.

[1184 byte] By [ama_banka] at [2007-11-27 1:47:51]
# 1

Okay. There are so many issues I do not know where to begin.

First, you should not have a JSP directly accessing a database for anything other than a trivial application. Do a Google search on 'model-view-controller' design pattern to see how to put your applications together.

Second, you are using Statement and manually escaping your SQL bind variables (parameters passed in). It is *far* more preferable for more reasons than I have time to detail to use a PreparedStatement. Do a Google search on JDBC and PreparedStatement to see how to use one.

Third, you are accessing the session, but I do not see anywhere in your code where you set the value in the session. Granted, it may be there, I just don't see it. However, you should not need to put anything in the session at all. Refactor using MVC (see above). Move all the data access code to the Servlet (at a minimum, better to create a separate data access object if possible). It should now be really apparent you can simply fetch the value passed in by the request itself using ServletRequest#getParameter(String).

- Saish

Saisha at 2007-7-12 1:11:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Also, 'urgent' is a relative term. I have many urgent items on my plate, and these will vary from your own. Offer Dukes if you want to get someone's attention. But generally, no one pays attention if a given poster thinks something is 'urgent'. Most posts here are. :^)- Saish
Saisha at 2007-7-12 1:11:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...