Hello there.
I got s few problems with my jsp pages. I am using MS Access dbase. Basically, i can retrieve data from the dbase n display them on the jsp page. I did this by posting href link from a HTML page to the jsp page where it displays the data.
Rite now my problem is:
1) Insert a new record.
the code is below:
<%@ page import="java.sql.*" %>
<HTML>
<HEAD><TITLE>Current words</TITLE>
</HEAD>
<BODY bgColor="#dfdfff">
<BR><CENTER>
<%
String submit = request.getParameter("Subm
it");
int x = Integer.parseInt("submit")
;
if(x == 1)
{
Connection con = null;
Class.forName("sun.jdbc.od
bc.JdbcOdb
cDriver");
con = DriverManager.getConnectio
n("jdbc:od
bc:PSM",""
,"");
java.sql.Statement stm = con.createStatement();
String a = request.getParameter("Mala
y");
String b = request.getParameter("Engl
ish");
String c = request.getParameter("Engl
ishDes");
String d = request.getParameter("Mala
yDes");
String sql = "Insert Into Trans (Malay, English, EnglishDes, MalayDes) Values ("+a+","+b+","+c+","+d+")"
;
ResultSet rs = stm.executeQuery(sql);
}
else
{
%>
<Center>
<H2>Current words</H2>
</Center>
<br>
<div align="center">
<form name="form1" method="post" action="pppos.jsp">
<p> Malay:
<input type="text" name="Malay" value="">
</p>
<p> English:
<input type="text" name="English"value="">
</p>
<p> EnglishDes:
<textarea name="EnglishDes"></textar
ea>
</p>
<p> MalayDes:
<textarea name="MalayDes"></textarea
>
</p>
<input name="Submit" type="submit" value="Submit">
<input type="reset" name="Reset">
</form>
<br>
<br>
<%
}
%>
<BR><BR><BR>
</CENTER>
</BODY>
</HTML>
i get the error at the below part....
[String submit = request.getParameter("Subm
it");
int x = Integer.parseInt("submit")
;]
the fields in the dbase are ID,Malay,English,EnglishDe
s,Malaydes
....where the ID is "Autonumber" and the primary key
what i originally think is...when I click the submit button, it shud post to a page where i will display "Data Insert Successful"...but rite now when i click the button it gives error...is it becoz the button is declared in String....
what I need is I want the parameters to be inserted into the dbase.....or is there any other way to insert apart from the code above which i tried..
2) 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....
3) I want to delete records that are displayed in the navigation bar....let's say i have 5 records....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 ....
4)i want to edit records (UPdate function)....the requirements are same like the delete function also.....
pls help me...desparately need a solution....