MyEclipse------PreparedStatement使用方法
testPreparedStatement.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'testPrepareStatement.jsp' starting page</title>
</head> <body>
<%
String url="jdbc:mysql://localhost:3306/student?useSSL=true";
String useName="root";
String password="2277092"; Connection conn=null;
Statement stmt=null; try{
Class.forName("com.mysql.jdbc.Driver");
//out.print("加载驱动类成功");
}
catch(ClassNotFoundException e){
out.print(e);
} try{
conn=DriverManager.getConnection(url,useName,password); PreparedStatement pstmtInsert=conn.prepareStatement(
"insert into classinfo(no,name,sex,major,phone,address,age,scoure) values(?,?,?,?,?,?,?,?);"); pstmtInsert.setInt(1, 6);
pstmtInsert.setString(2,"沐白");
pstmtInsert.setString(3, "男");
pstmtInsert.setString(4,"网络工程");
pstmtInsert.setString(5, "2277092");
pstmtInsert.setString(6,"五邑大学");
pstmtInsert.setInt(7, 23);
pstmtInsert.setInt(8,90); pstmtInsert.executeUpdate(); pstmtInsert.close();
out.print("插入数据成功");
}
catch(SQLException e){
out.print(e);
}
finally{
try{
if(conn!=null)
conn.close();
}
catch(Exception e){
out.print("断开数据库连接出现异常");
}
}
%>
</body>
</html>
MyEclipse------PreparedStatement使用方法的更多相关文章
- MyEclipse SVN安装方法
方法一:在线安装 1.打开HELP->MyEclipse Configuration Center.切换到SoftWare标签页. 2.点击Add Site 打开对话框,在对话框Name输入Sv ...
- myeclipse安装svn方法汇总
myeclipse安装svn方法汇总 博客分类: eclipse MyEclipse6.5安装SVN插件,掌握了几种方法,本节就像大家介绍一下MyEclipse6.5安装SVN插件的三种方法,看完 ...
- (MyEclipse) MyEclipse完美破解方法(图)
http://photo.blog.sina.com.cn/list/blogpic.php?pid=53358777td408badc4071&bid=533587770101dd03&am ...
- MyEclipse断点调试方法
MyEclipse断点调试方法 最基本的操作是: 1, 首先在一个java文件中设断点,然后运行,当程序走到断点处就会转到debug视图下, 2, F5键与F6键均为单步调试,F5是step into ...
- 关于JDK+Tomcat+eclipse+MyEclipse的配置方法
说一下关于JDK+Tomcat +eclipse+MyEclipse的配置方法: 1.jdk的配置 我用的是jdk1.6版本,与jdk1.5方法相同.执行完安装程序后就要在进行一下配置,步骤如下:右键 ...
- [转载] 关于PreparedStatement.addBatch()方法
Statement和PreparedStatement的区别就不多废话了,直接说PreparedStatement最重要的addbatch()结构的使用. 1.建立链接(打电话拨号) Connecti ...
- Eclipse/Myeclipse生成serialVersionUID方法
serialVersionUID作用: 序列化时为了保持版本的兼容性,即在版本升级时反序列化仍保持对象的唯一性. 如果你修改代码重新部署后出现序列化错误,可以考虑给相应的类增加serialVersio ...
- 关于PreparedStatement.addBatch()方法 (转)
Statement和PreparedStatement的区别就不多废话了,直接说PreparedStatement最重要的addbatch()结构的使用. 1.建立链接,(打电话拨号 ) Connec ...
- [转]关于PreparedStatement.addBatch()方法
Statement和PreparedStatement的区别就不多废话了,直接说PreparedStatement最重要的addbatch()结构的使用. 1.建立链接,(打电话拨号 ) Connec ...
- Myeclipse的优化方法
近期在实习,公司给分配了新的电脑,可是不知道怎么弄得,总是弄得非常卡,没办法仅仅有自己好好整理一下电脑了,另外.为了提高编程的效率.顺便也把Myeclipse也优化了一下. 第一步: 取消自己主动va ...
随机推荐
- 使用EasyUI要引入哪些文件
使用EasyUI,一般需要导入如下文件 <link rel="stylesheet" type="text/css" href="../reso ...
- poj 1411 Calling Extraterrestrial Intelligence Again(超时)
Calling Extraterrestrial Intelligence Again Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- C语言 预处理一(文件包含--#include)
//预处理命令不需要在结束末尾加":" //#inlude可以包含任意类型的文件 //#inlude 将一个源文件的全部内容包含到另一个源文件中,成为它的一个部分,文件包含的一般格 ...
- ActionBar在Android2.x的实现,类似新版微信界面。
ActionBar完美兼容Android4.x的机型,虽然现在Android2.x的系统越来越少,还有有一部分人使用的仍是2.x的系统,所以我们还得考虑着兼容性问题. 对比图: Test例子与微信的对 ...
- Java系列:报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
Javaweb工程类中没有添加Tomcat运行时相关类导致. 下面是具体的解决方法: 1.右击web工程->属性或Build Path->Java Build Path->Libra ...
- iOS开发UI篇—popoverController简单介绍(ipad)
一.简单介绍 1.什么是UIPopoverController 是iPad开发中常见的一种控制器(在iPhone上不允许使用) 跟其他控制器不一样的是,它直接继承自NSObject,并非继承自UIVi ...
- Html中metra的含义
from: http://dev.csdn.net/article/60/60902.shtm meta是用来在HTML文档中模拟HTTP协议的响应头报文.meta 标签用于网页的<head&g ...
- mysql慢查询分析工作pt-query-digest的使用
一.简单安装 wget percona.com/get/pt-query-digest chmoe u+x pt-query-digest 二.简单使用 ./pt-query-digest /var/ ...
- Bootstrap系列 -- 37. 基础导航样式
Bootstrap框架中制作导航条主要通过“.nav”样式.默认的“.nav”样式不提供默认的导航样式,必须附加另外一个样式才会有效,比如“nav-tabs”.“nav-pills”之类.比如右侧代码 ...
- 【BZOJ1008】【HNOI2008】越狱(数学排列组合题)
1008: [HNOI2008]越狱 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 3140 Solved: 1317[Submit][Status] ...