【struts2】一个BBS论坛初步显示util
来源:互联网 发布:webp转换软件 编辑:程序博客网 时间:2024/05/01 11:24
/*** 书本:【struts2】* 功能:连接数据库使用的* 文件:CategoryService.java* 时间:2014年10月30日16:28:26* 作者:cutter_point*/package com.whqg.bbs2009.util;import java.sql.DriverManager;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class DB {//创建数据库连接public static Connection createConn(){Connection conn=null;try {//得到驱动Class.forName("com.mysql.jdbc.Driver");//连接数据库conn=DriverManager.getConnection("jdbc:mysql://localhost/bbs2009", "root", "xiaofeng2014");} catch (ClassNotFoundException e) {e.printStackTrace();} catch (SQLException e) {e.printStackTrace();}return conn;}public static PreparedStatement prepare(Connection conn, String sql){PreparedStatement ps=null;try {ps=conn.prepareStatement(sql);} catch (SQLException e) {e.printStackTrace();}return ps;}public static void close(Connection conn){if(conn == null) return;try {conn.close();conn=null;} catch (SQLException e) {e.printStackTrace();}}public static void close(Statement stmt){if(stmt == null) return;try {stmt.close();stmt=null;} catch (SQLException e) {e.printStackTrace();}}public static void close(ResultSet rs){if(rs == null) return;try {rs.close();rs=null;} catch (SQLException e) {e.printStackTrace();}}}
0 0
- 【struts2】一个BBS论坛初步显示util
- 【struts2】一个BBS论坛初步显示
- 【struts2】一个BBS论坛初步显示action
- 【struts2】一个BBS论坛初步显示model
- 【struts2】一个BBS论坛初步显示service
- 【struts2】一个BBS论坛初步显示的Category-add.jsp
- 【struts2】一个BBS论坛初步显示Category-addInput.jsp
- 【struts2】一个BBS论坛初步显示Category-delete.jsp
- 【struts2】一个BBS论坛初步显示Category-list.jsp
- 【struts2】一个BBS论坛初步显示Category-update.jsp
- 【struts2】一个BBS论坛初步显示Category-updateInput.jsp
- 【struts2】一个BBS论坛初步显示index.html
- 【struts2】一个BBS论坛初步显示struts.xml的配置
- 【struts2】一个BBS论坛初步显示web.xml
- 【struts2】一个BBS论坛初步显示sql数据库的配置,这里使用的是MySQL
- 搞了一个论坛玩玩!http://lupeiqing.3322.org/bbs
- 想找个BBS论坛
- BBS论坛需求分析
- Structs2参数传递
- ngx_lua与go高并发性能对比
- 守护进程的创建-keepalived源码解析
- 杭电1518 Square(DFS+剪枝)
- 2_DirectX_绘制三角形
- 【struts2】一个BBS论坛初步显示util
- 【Android数据传递】Intent传递List和Object和List<Object>(附源码)
- ubuntu下链接手机调试android程序,ADB无法识别手机
- 2014.11.09 eclipse 快速集成jetty
- 深入浅出ThreadLocal
- 通过反射得到泛型的类型参数
- 输出数字菱形
- JDBC编程之creatstatement()的用法
- 国产操作系统——中科方德桌面操作系统