Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

display data from MS access,use navigation bar,delete current record..urgen

843836Jan 29 2004 — edited Jan 29 2004
hello there...

i am desparately seeking a solution for the problems below...
i am currently using Tomcat 3.1, MS Access database, JSP...

1) i need to display the records with a navigation bar...it's something like in macromedia dreamweaver built in function...recordset navigation bar....
it's like there will be 4 links which are "First","Previous", "Next", "Last"...
i already built the interface but i dun have the necessary codes to display the recordset....

2) I want to delete records that are displayed in the navigation bar....let's say i have 5 records from the table....1st record will be displayed by default rite..when i click "Next" it should display the 2nd record....how could i delete this record......How could i implement this function...the view n delete must be in the same page rite...it shud the post to a page where it says "data successfully deleted"....shud the ID put as the hidden value....im not familiar how this hidden value works ....


let me explain,both the questions are related

DELETE_NAV.JSP
what this page does is, it will retrieve the datas from the table..there are 5 fields in this table, which are ID(autonumber),Malay(text),English(text),MalayDes(text),EnglishDes(text)....ID is the primary key...but i will display only the 4 fields on the page...i wont display the ID field...

in this page i will have links "Previous", "Next", "First", "Last".. ... i will have a button which "Delete"....when i click it, the data that are currently displayed on the 4 text fields will be deleted...it will be posted to DELETE.JSP.....
as the ID is primary key for the record and it is the autonumber...i thought of putting it in "Next" and"PRevious" links...if i click "Next",the ID will +1, and shows the next record...

the problem is,
1)it is not displaying any record on the DELETE_NAV.JSP...
2)shud i remove the input text box that are used to display the record, if i remove it, then what is the alternative way to display th data...
3)how about the ID field, shud it be in the hidden value,if in the hidden value then, how could it help to display the current record...if i want to delete the record,it will be posted to DELETE.JSP, then what field shut it "request.getparameter"...if the 4 records are displayed in the text boxes in DELETE_NAV.JSP, then i could retrieve the 4 current datas and delete them...then how to delete the ID....I NEED TO COMPLETELY REMOVE THE 5 FIELDS FROM THE TABLE...
4)if the ID in hidden value...then how it will be used to delete the current record...will be posted to DELETE.JSP as i did below to delete the desired record.....

5) the DELETE_NAV.JSP file...doesn't display any record at all....when i click "NExt"..the address becomes "http://localhost:8080/thesis/delete_nav.jsp?id=1"...(im not really sure, but it displays somethign to do with ID is 1....no matter how many time i click next, it will display 1 only)....when i click the DELETE button, there will be MICROSOFT INTERNAL 500 SERVER ERROR..."Data type mismatch error"..

plls look into my code below and tell me any suggesstions or solutions to my problem...i am really desparate here...

DEELE_NAV.JSP

<%@ page import="java.sql.*" %>
<HTML>
<HEAD><TITLE>Current words</TITLE>
</HEAD>

<BODY bgColor="#dfdfff">
<BR>

<p align="center"><font size="5" color="#000080">Current words</font><br>
</p>
<%
Connection con = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:PSM","","");
java.sql.Statement stm = con.createStatement();

String sql = "SELECT * FROM trans";
ResultSet rs = stm.executeQuery(sql);

int pageSize = 1;
int ii;
String strRecNo = request.getParameter( "ID" );
int recNo = (strRecNo==null) ? 0 : Integer.parseInt( strRecNo );
for( ii = recNo; ii > 0; ii -- )
rs.next(); // skip records.
for( ii = 0; ii < pageSize && rs.next(); ii++ )
{ // display the record
%>
<form name="form1" method="post" action="delete.jsp">

<p align = "center"><font color="#000080"> Malay:
<input type="text" name="Malay" value="">
</font></p>
<p align = "center"><font color="#000080"> English:
<input type="text" name="English"value="">
</font></p>

<p ><font color="#000080">EnglishDes:</font></p>
<p><font color="#000080">
<textarea name="EnglishDes"></textarea>
</font></p>

<p><font color="#000080"> MalayDes:</font></p>
<p><font color="#000080">
<textarea name="MalayDes"></textarea>
</font></p>
<input name="ID" type="hidden" value="">
<div align="center">
<p>
<input name="Submit" type="submit" value="Delete">
<input type="reset" name="Reset">
</p>
<%
}
%>
<p>
<% if( recNo >= pageSize )
{ %>
<a href="?recno=<%=recNo - pageSize%>">previous</a>
<% } %>
<a href="?recno=<%=recNo + pageSize%>">next</a>

</p>
</div>
</form>
<%

stm.close();
con.close();
%>
</BODY>
</HTML>


DELETE.JSP

<%@ page import="java.sql.*" %>
<HTML>
<HEAD><TITLE>Delete words</TITLE>
</HEAD>

<BODY bgColor="#dfdfff">
<strong><BR>
</strong>

<strong><BR>
<BR>
</strong>

<p align="center"><font size="5" color="#000080">Current words</font><br>
</p>

<%
String e = request.getParameter("ID");

Connection con = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:PSM","","");
java.sql.Statement stm = con.createStatement();

String sqldelete = "DELETE * FROM trans WHERE ID = '"+e+"'" ;
//PreparedStatement ps = con.prepareStatement( sqldelete );
//ps.executeUpdate();
int row = stm.executeUpdate(sqldelete);
%>
<p align="center"><font size="5" color="#000080">WORDS SUCCESSFULLY DELETED!!!</font><br></p>
<%

stm.close();
con.close();
%>

</BODY>
</HTML>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2004
Added on Jan 29 2004
1 comment
115 views