jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx

上传人:b****3 文档编号:18246878 上传时间:2022-12-14 格式:DOCX 页数:8 大小:191.43KB
下载 相关 举报
jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx_第1页
第1页 / 共8页
jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx_第2页
第2页 / 共8页
jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx_第3页
第3页 / 共8页
jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx_第4页
第4页 / 共8页
jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx_第5页
第5页 / 共8页
点击查看更多>>
下载资源
资源描述

jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx

《jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx》由会员分享,可在线阅读,更多相关《jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx(8页珍藏版)》请在冰豆网上搜索。

jsp实现连接数据库分页浏览增删改查等功能精Word文件下载.docx

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(;

编号

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1