基本sql连接数据库
来源:互联网 发布:打开照片的软件 编辑:程序博客网 时间:2024/05/18 09:44
//获取连接,向数据库插入数据
Connection connection=null;
Statement stmt=null;
try {
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/db_ssh","root","123456");
stmt=connection.createStatement();
String sql="insert into usermes values(null,'"+name+"','"+password+"')";
System.out.println("sql"+sql);
stmt.executeUpdate(sql);
response.sendRedirect("registerSuccess.jsp");
} catch (ClassNotFoundException e) {
response.sendRedirect("registerSuccess.jsp");
e.printStackTrace();
} catch (SQLException e) {
response.sendRedirect("registerSuccess.jsp");
e.printStackTrace();
}finally{
if(stmt!=null){
stmt.close();
stmt=null;
}
if(connection!=null){
connection.close();
connection=null;
}
}
%>
Connection connection=null;
Statement stmt=null;
try {
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/db_ssh","root","123456");
stmt=connection.createStatement();
String sql="insert into usermes values(null,'"+name+"','"+password+"')";
System.out.println("sql"+sql);
stmt.executeUpdate(sql);
response.sendRedirect("registerSuccess.jsp");
} catch (ClassNotFoundException e) {
response.sendRedirect("registerSuccess.jsp");
e.printStackTrace();
} catch (SQLException e) {
response.sendRedirect("registerSuccess.jsp");
e.printStackTrace();
}finally{
if(stmt!=null){
stmt.close();
stmt=null;
}
if(connection!=null){
connection.close();
connection=null;
}
}
%>
- 基本sql连接数据库
- JDBC连接数据库&SQL基本操作
- Ado 连接数据库 Sql Server2000 及基本数据库操作
- C#连接数据库最基本操作之sql语句 DML
- PHP基本连接数据库
- PHP基本连接数据库
- 数据库 基本sql应用
- SQL数据库基本操作
- SQL数据库基本语法
- SQL数据库基本语句
- 基本数据库sql 语言,
- 数据库SQL基本语法
- 数据库基本SQL语句
- Sql数据库基本操作
- 数据库基本sql语句
- sql数据库基本语句
- SQL数据库基本操作
- SQL数据库基本操作
- 七夕夜、离别,涵情经河岸
- org.hibernate.LazyInitializationException: could not initialize proxy 解决
- 数据乱码 多一个为空的一字节乱码
- 读取文件的问题
- 线程的生命周期
- 基本sql连接数据库
- SimpleAudioEngine方法playEffect参数
- android那些事--- Handler和Looper的纯洁关系
- WPF 页面跳转
- Java事务的原理与应用
- animation相关类
- Compass-指南针(主要用到RotateAnimation和SensorEventListener)
- 关于Qt下如何获取屏幕尺寸以及打印的代码示例
- 从那一天起,你就成了我的全部