<%@page import ="java.sql.*" %>
<%@page import="java.util.*" %>
<%!
Connection conn=null;
Statement stmt=null;
PreparedStatement ps=null;
ResultSet rs=null;
String connURL="jdbc:mysql://localhost:3306/customer";
int customer_id=0;
int amount=0;
int flag=1;
int tempAmount=0;
%>
<%
customer_id=Integer.parseInt(request.getParameter("custid"));
amount=Integer.parseInt(request.getParameter("amt"));
try
{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection(connURL,"root","root");
stmt=conn.createStatement();
rs=stmt.executeQuery("SELECT *FROM cust");
ps=conn.prepareStatement("UPDATE cust SET amount=? WHERE customerid=?");
out.println("connection made");
while(rs.next())
{
int custid=rs.getInt("customerid");
if(custid==customer_id)
{
flag=0;
out.println("statement execute");
tempAmount=rs.getInt("amount");
out.println("amount" +tempAmount);
tempAmount=tempAmount+amount;
out.println("amount" +tempAmount);
//ps.setInt(1,customer_id);
ps.setInt(4,21000);
out.println(" update is made");
ps.executeUpdate();
out.println("Even update is made");
}
}
rs.close();
conn.close();
out.println("connection closed");
}
catch(Exception e)
{
e.printStackTrace();
}
%>
hI I AM sending the code basically its in
JSp ..but it simple coz i am using any scriptlet and in which i am doing all the logic work...
and even i sending the Url det i am using for this application..
http://localhost:8080/try.jsp?custid=2&amt=350 and there is no error only o/p til
connection made statement execute amount20000 amount20350
measn it accessing the data but cudnt update though PreparedStatement..
Hope this info help you to narrow your solution..
Again ,
Thanks in advance