Skip to main content

how to update database with (ms access) in Jsp

1 reply [Last post]
ducnghia_12a4
Offline
Joined: 2012-04-14
Points: 0

oh , i have some problems with my project....

i can't update field in my database .....

1 have a test.jsp

<form action="updatetinhocprocess.jsp" method="post">
<table width="373" border="0">
  <tr>
    <td width="61">tên sách</td>
    <td width="296">
        <input type="text" name="a1"/>
    </td>
  </tr>
  <tr>
    <td>hình sách</td>
    <td><input type="text" name="a2"/></td>
  </tr>
 
</table>
         <input type="submit" value="update">
</form>

and one file to process code ....

 <%
                            String tensach= request.getParameter("a1");
                          String hinhsach= request.getParameter("a2");
  
                      

                         
request.setCharacterEncoding("UTF-8");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + application.getRealPath("/data.mdb") + "; useUnicode=true; characterEncoding=UTF8";
Connection con = DriverManager.getConnection(url);
Statement stmt = con.createStatement();
String ps = "update sachit set hinhsach='"+hinhsach+"' where tensach='"+tensach+"'";               
ResultSet rs = stmt.executeQuery(ps);

                  
        
        %>
       
       
        <%
                     
                   stmt.close();
                   con.close();
        %>

what's for wrong .... ??

this's a pic for data
http://nk0.upanh.com/b5.s13.d3/f6f3b96cc65fbd854d1323dba2061146_43450370.capture.png

when i compile and run on browser....error

in line 34

34: ResultSet rs = stmt.executeQuery(ps);

help me ...
thanks for all ....

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
weaam_hafez
Offline
Joined: 2012-04-26
Points: 0

Hello

this is an update statement not a query so you need to say stmt.executeUpdate(ps);