473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem in accessing bean

public class area
{
int id;


public void setId(int id)
{
this.id=id;
}
public String deleterecord()
{
String message="";

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:Odbc:myDSN", "sa","");
PreparedStatement st=con.prepareStatement("delete from tbl_area where id=?");
st.setInt(1,id);
st.executeUpdate();

message="record deleted";
}
catch(Exception e)
{
message=e.getMessage();
}
return message;
}
}
this is my bean class
-----------------------------------------------------------------------------------------------------
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="are" class="area.area" scope="page">
<%
String s=request.getParameter("ares");
if(s!=null)
{

%>


<jsp:setProperty name="are" property="id" param="ares"/>



<%
}
%>
</jsp:useBean>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:Odbc:myDSN", "sa","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select id,aname from tbl_area where status='Y'");



%>

<form action="area.jsp" method="get">

Select area:
<select name="areas" >
<option value="">select area</option>
<%



while(rs.next())
{

%>
<!--<option value="saltlake">saltlake</option>-->

<option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>
<%
}

%>

</select>
<br><br><br>

<input type="submit" name="Submit" value="edit">
<input type="submit" name="Submit" value="delete">
</form>
<%
}
catch(Exception e)
{out.println(e);}



try{
if(request.getParameter("submit").equals("delete") )
{ out.println("sumanta");
String delmessage=are.deleterecord();
out.println(delmessage);
}
}

catch(Exception E)
{
}

%>
can any help me solving this bcuz I can't delete data....
Mar 14 '08 #1
1 1212
Stang02GT
1,208 Expert 1GB
public class area
{
int id;


public void setId(int id)
{
this.id=id;
}
public String deleterecord()
{
String message="";

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:Odbc:myDSN", "sa","");
PreparedStatement st=con.prepareStatement("delete from tbl_area where id=?");
st.setInt(1,id);
st.executeUpdate();

message="record deleted";
}
catch(Exception e)
{
message=e.getMessage();
}
return message;
}
}
this is my bean class
-----------------------------------------------------------------------------------------------------
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="are" class="area.area" scope="page">
<%
String s=request.getParameter("ares");
if(s!=null)
{

%>


<jsp:setProperty name="are" property="id" param="ares"/>



<%
}
%>
</jsp:useBean>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:Odbc:myDSN", "sa","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select id,aname from tbl_area where status='Y'");



%>

<form action="area.jsp" method="get">

Select area:
<select name="areas" >
<option value="">select area</option>
<%



while(rs.next())
{

%>
<!--<option value="saltlake">saltlake</option>-->

<option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>
<%
}

%>

</select>
<br><br><br>

<input type="submit" name="Submit" value="edit">
<input type="submit" name="Submit" value="delete">
</form>
<%
}
catch(Exception e)
{out.println(e);}



try{
if(request.getParameter("submit").equals("delete") )
{ out.println("sumanta");
String delmessage=are.deleterecord();
out.println(delmessage);
}
}

catch(Exception E)
{
}

%>
can any help me solving this bcuz I can't delete data....
sumantabardhan,

Welcome! It appears that your question will fall into one of or specific forums. Please check out the Java and JavaScript forms, and PM a moderator and ask them to move your post to the correct forum.


thanks!
Mar 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Amy | last post by:
When accessing my JSP I get the following error: org.apache.jasper.JasperException: Missing message for key button.next Can anyone tell me what the problem is? I have tried to figure this out...
0
by: Geno Timlin | last post by:
In Weblogic 7.x, I can define a bean using the Struts bean:define tag and then access the bean's methods in a script. But in Weblogic 8 the same code does not work. <logic:iterate name="myForm"...
1
by: bhadram | last post by:
hello, Please help me the jsp problem. I used java bean and written the bean and copyied in WEB-INF/classes of particular application but the compiler cannot locate the bean it is giving error...
13
by: Tom Bean | last post by:
I developed a C# application to automate input to elements of a web page displayed in an AxWebBrowser control. The app calls GetEnumerator() on the HTMLDocument's HTMLElementCollection (i.e....
0
by: kisc71117 | last post by:
When accessing my JSP I get the following error: org.apache.jasper.JasperException: Missing message for key "button.add" my error message javax.servlet.ServletException: Missing message for key...
2
by: nvidia1 | last post by:
Hi this is my first post but so far this is pretty good site. I have a file called index.html with the following code: <!-- index.html --> <html> <head><title>Student Registration...
0
by: radhi | last post by:
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html>...
2
dmjpro
by: dmjpro | last post by:
I have five source files. public class SpringAOP implements SpringAOPInterface { public void showMessage() { System.out.println("I m learning Spring+AOP, & i really enjoying...
0
by: buk110 | last post by:
Hi everyone, I'm new to using JAVA and I'm trying to interact with a web service I wrote in C# I downloaded Netbeans & followed the instructions to point to the wsdl file I navigated to my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.