jsp读写oracle数据库,jsp接收数据写入oracle数据库,该如何解决

当前位置:我的异常网» J2EE » jsp接收数据写入oracle数据库,该如何解决

jsp接收数据写入oracle数据库,该如何解决

www.myexceptions.net  网友分享于:2013-02-08  浏览:31次

jsp接收数据写入oracle数据库

html提交数据:

报名系统

院新生才艺大赛报名系统


姓名:

学号:

性别:

出生年月:

1988

1989

1990

1991

1992

1993

1994

1995

1

2

3

4

5

6

7

8

9

10

11

12

政治面貌:

团员

群众

党员

民族:

籍贯:

专业班级:

计算机

计科

通信

信安

网工

中加

1

2

3

4

5

6

特长:

联系方式:

参赛类别:

声乐

器乐

主持

舞蹈

曲艺

其他

个人介绍:

© 2011 SIPC 版权所有 By:McDong

jsp代码:

public static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver" ;

public static final String DBURL = "jdbc:oracle:thin:@localhost:1521:orcl" ;

public static final String DBUSER = "scott" ;

public static final String DBPASS = "admin" ;

%>

Connection conn = null ;

PreparedStatement pstmt = null ;

ResultSet rs = null ;

Statement sm = null;

%>

String stuname = request.getParameter("stuname") ;// 接收表单参数

String stumun = request.getParameter("stumun") ;// 接收表单参数

String sex = request.getParameter("sex") ;

String biryear = request.getParameter("biryear") ;

String birmon = request.getParameter("birmon") ;

String mianmao = request.getParameter("mianmao") ;

String nation = request.getParameter("nation") ;

String home = request.getParameter("home") ;

String major = request.getParameter("major") ;

String stuclass = request.getParameter("stuclass") ;

String techang = request.getParameter("techang") ;

String tel = request.getParameter("tel") ;

String choose = request.getParameter("choose") ;

String numberroduce = request.getParameter("numberroduce") ;

%>

conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;

String insert = "insert into apply values('"+stuname+"',"+stumun+",'"+sex+"','"+biryear+"','"+birmon+"','"+mianmao+"','"+nation+"','"+home+"','"+major+"','"+stuclass+"','"+techang+"','"+tel+"','"+choose+"','"+numberroduce+"')";

%>

之后应该怎么写入数据库? 已经写出了sql语句,后边不回了,网上的没看明白,麻烦大家了...

------解决方案--------------------

楼主用得jdbc吧 到conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;

这一步,你已经获取数据库连接了 之后就按jdbc的那6步走呗:

①加载驱动

②得到连接

--------------------------------------------

③获取Statement

④准备sql操作数据库

⑤得到结果集

⑥关闭资源

接下来你获取statement对象,执行SQL语句,得到结果集,最后关闭连接 就ok了

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值