Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 16th, 2006, 02:58 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default prepared statement

<div align="left">iam trying jdbc concepts like insert ,delete and updation using prepared statements with jsp.
iam having problem with updation and deletion.i have no problem in insertion[ all using prepared statement].During updation and deletion it triggers an sqlexception as,"COUNT field incorrect".i tried with the following code.
could you please help me to solve this problem?


[u]FOR UPDATION </u>


<%@ page language="java" import ="java.sql.*" %>
<%
String empp1=request.getParameter("empp");
String nam1=request.getParameter("nam");
String prtt1=request.getParameter("prtt");
String stdtt1=request.getParameter("stdtt");
String enddtt1=request.getParameter("enddtt");
%>
<html>
<head><title>DELAY TRACKING DETAILS</title>
<script language="javascript">
function fn1()
{
    document.fn.action="http://localhost:8000/sbc/plpage.html";
    document.fn.submit;
}
</script>
</head>
<body bgcolor="fffff0">
<br><br><br><br>


<%
Connection con=null;
try
{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:eedsn", "","");
    PreparedStatement st=con.prepareStatement("update empl set name=?,pr_tit=?,enddt=? where empid=? ");
    st.setString(2,nam1);
    st.setString(3,prtt1);
    st.setString(4,enddtt1);
    st.executeUpdate();
}
catch(Exception d)
{
    out.println("cannot update the records");
}
%>
<form method=get action="http://localhost:8000/sbc/plpage.html">
<input align=center type=image src="c:\com\sanrm\exit.gif" onclick="fn1()">
</form>
</body>
</html>


 [u]FOR DELETION </u>


<%@ page language="java" import ="java.sql.*" %>
<html>
<head><title>Employee Details</title>
</head>
<body bgcolor="fffff0">
<br><br><br><br>
<%
String eidd1=request.getParameter("eidd");
Connection con=null;
try
{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:eedsn", "","");
    PreparedStatement st=con.prepareStatement("delete from empl where empid=?");
    response.sendRedirect("http://localhost:8000/sannew/pstatus1.jsp");
}
catch(Exception d)
{
    out.println("cannot recognize the records"+d);
}
%>
</body>
</html>








    </div id="left">






Similar Threads
Thread Thread Starter Forum Replies Last Post
Prepared SQL VS. Regular Queries nikotromus Beginning VB 6 1 June 24th, 2006 10:08 AM
problem in prepared Statement abhit_kumar Java Databases 2 March 23rd, 2006 09:34 AM
Prepared SQL VS. Regular Queries nikotromus Pro VB 6 0 January 17th, 2006 08:37 PM
Prepared SQL VS. Regular Queries nikotromus Pro VB Databases 0 January 17th, 2006 08:35 PM
problem in prepared statement abhit_kumar JSP Basics 1 November 25th, 2004 04:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.