jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx
《jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx》由会员分享,可在线阅读,更多相关《jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx(8页珍藏版)》请在冰豆网上搜索。
![jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx](https://file1.bdocx.com/fileroot1/2022-12/14/55a58958-d67f-418c-a338-4dc23962c9f1/55a58958-d67f-418c-a338-4dc23962c9f11.gif)
Stringoracledriver="
oracle.jdbc.driver.OracleDriver"
;
StringoracleUrl="
jdbc:
oracle:
thin:
@localhost:
1521:
ORACLE"
Stringusername="
scott"
Stringpassword="
tiger"
Connectioncon;
Class.forName(oracledriver;
con=DriverManager.getConnection(oracleUrl,username,password;
intintPageSize;
intintRowCount;
intintPageCount;
intintPage;
StringstrPage;
inti;
intPageSize=10;
strPage=request.getParameter("
page"
if(strPage==null{
intPage=1;
}else{
intPage=java.lang.Integer.parseInt(strPage;
if(intPage<
1intPage=1;
}
Statementstmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY;
Stringsql="
select*fromworker"
ResultSetrs=stmt.executeQuery(sql;
rs.last(;
intRowCount=rs.getRow(;
intPageCount=(intRowCount+intPageSize-1/intPageSize;
if(intPage>
intPageCount
intPage=intPageCount;
if(intPageCount>
0{
rs.absolute((intPage-1*intPageSize+1;
i=0;
while(i
%
rs.next(;
i++;
工号
姓名
性别
工龄
工资
%=rs.getString("
id"
name"
sex"
workyear"
sal"
第<
%=intPage%>
页共<
%=intPageCount%>
页
if(intPage
下一页
1{
上一页
rs.close(;
stmt.close(;
con.close(;
Input.jsp代码如下:
提交"
>
取消"
Inputcheck.jsp代码如下:
已添加员工信息
StringempID=request.getParameter("
empID"
byte[]b=empID.getBytes("
ISO-8859-1"
empID=newString(b,"
StringempName=request.getParameter("
empName"
byte[]b1=empName.getBytes("
empName=newString(b1,"
StringempSex=request.getParameter("
empSex"
byte[]b2=empSex.getBytes("
empSex=newString(b2,"
StringempWorkyear=request.getParameter("
empWorkyear"
byte[]b3=empWorkyear.getBytes("
empWorkyear=newString(b3,"
StringempSal=request.getParameter("
empSal"
byte[]b4=empSal.getBytes("
empSal=newString(b4,"
Connectioncon=DriverManager.getConnection(oracleUrl,username,password;
Statementstmt=con.createStatement(;
Stringsql="
insertintoworkervalues('
"
+empID+"
'
'
+empName+"
+empSex+"
"
+empWorkyear+"
+empSal+"
stmt.executeUpdate(sql;
已删除员工信息
Stringoracledriver1="
StringoracleUrl1="
Stringusername1="
Stringpassword1="
Class.forName(oracledriver1;
Connectioncon1=DriverManager.getConnection(oracleUrl1,username1,password1;
Statementstmt1=con1.createStatement(;
Stringsql1="
deletefromworkerwhereempName='
韩信'
stmt1.executeUpdate(sql1;
stmt1.close(;
con1.close(;
已更改员工信息
Stringoracledriver2="
StringoracleUrl2="
Stringusername2="
Stringpassword2="
Class.forName(oracledriver2;
Connectioncon2=DriverManager.getConnection(oracleUrl2,username2,password2;
Statementstmt2=con2.createStatement(;
Stringsql2="
updateworkersetempName='
李莉莉'
whereempName='
Kababa'
stmt2.executeUpdate(sql2;
stmt2.close(;
con2.close(;
经过以上操作后,Worker表如下:
Stringoracledriver3="
StringoracleUrl3="
Stringusername3="
Stringpassword3="
Class.forName(oracledriver3;
Connectioncon3=DriverManager.getConnection(oracleUrl3,username3,password3;
Statementstmt3=con3.createStatement(;
Stringsql3="
Select*fromworker"
ResultSetrs=stmt3.executeQuery(sql3;
while(rs.next({
}rs.close(;
stmt3.close(;
con3.close(;
编号