资源简介
这是一个用jsp语言写的一个用户注册和登录系统,数据库用的是MySQL,连接方式封装到类里面。
代码片段和文件信息
package com;
import java.sql.*;
import java.lang.ClassNotFoundException;
public class baseConn {
private Connection conn = null;
private Statement stmt = null;
private PreparedStatement ps = null;
private ResultSet rs = null;
public baseConn() throws SQLExceptionClassNotFoundException{
try
{
String url = “jdbc:mysql://localhost:3306/mytest“;
Class.forName(“com.mysql.jdbc.Driver“);
conn = DriverManager.getConnection(url“root““6121485“);
}catch(SQLException e)
{
System.out.println(“Error occured when Connect Database:“+e);
throw e;
}
catch(ClassNotFoundException e)
{
System.out.println(“Error occured when Connect Database:“+e);
throw e;
}
}
public PreparedStatement preparedStatement(String sql) throws SQLException
{
try
{
ps = conn.prepareStatement(sql);
return ps;
}catch(SQLException e)
{
System.out.println(“Error occured when Connect Database:“+e);
throw e;
}
}
/**
* 执行静态 SQL 查询语句并返回它所生成结果的对象
* */
public ResultSet executeQuery(String sql) throws SQLException
{
rs = null;
try {
rs = stmt.executeQuery(sql);
}
catch (SQLException ex) {
System.out.println(“Error occured when query database:“ + ex);
throw ex;
}
return rs;
}
/**
* 执行静态SQL更新语句并返回影响数据条数
* */
public int executeUpdate(String sql) throws SQLException
{
try {
conn.setAutoCommit(false);
int re = stmt.executeUpdate(sql);
conn.commit();
return re;
}
catch (SQLException e) {
conn.rollback();
System.out.println(“Error occured when update database:“ + e);
throw e;
}
}
/**
* 执行预编译的SQL查询语句
*
* */
public ResultSet executeQuery() throws SQLException
{
try {
return ps.executeQuery();
}
catch (SQLException e) {
System.out.println(“Error occured when query database:“ + e);
throw e;
}
}
/**
* 执行预编译的SQL更新语句
*
* */
public int executeUpdate() throws SQLException
{
try {
conn.setAutoCommit(false);
int r = ps.executeUpdate();
conn.commit();
return r;
}
catch (SQLException e) {
conn.rollback();
System.out.println(“Error occured when update database:“ + e);
throw e;
}
}
/**
* 数据库关闭操作
* */
public boolean closeDB() throws SQLException
{
try {
if (this.rs != null)
rs.close();
if (this.stmt != null)
this.stmt.close();
if (this.ps != null)
this.ps.close();
if (this.conn != null)
conn.close();
return true;
}
catch (SQLException e) {
System.out.println(“Error occured when close database:“ + e);
throw e;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 542 2009-07-13 09:05 testMySQL\.classpath
文件 300 2009-07-11 11:26 testMySQL\.myme
文件 1227 2009-07-11 12:37 testMySQL\.project
文件 334 2009-07-11 11:26 testMySQL\.settings\org.eclipse.jdt.core.prefs
文件 2990 2009-07-12 15:40 testMySQL\src\com\ba
文件 2520 2009-07-13 10:27 testMySQL\src\com\CheckLogin.java
文件 1848 2009-07-12 15:11 testMySQL\WebRoot\checkLogin.jsp
文件 1967 2009-07-12 14:57 testMySQL\WebRoot\login.jsp
文件 39 2009-07-11 11:26 testMySQL\WebRoot\me
文件 2026 2009-07-13 10:35 testMySQL\WebRoot\register.jsp
文件 2162 2009-07-13 10:54 testMySQL\WebRoot\register_post.jsp
文件 3162 2009-07-13 09:05 testMySQL\WebRoot\WEB-INF\classes\com\ba
文件 2118 2009-07-13 10:27 testMySQL\WebRoot\WEB-INF\classes\com\CheckLogin.class
文件 709922 2008-05-12 19:14 testMySQL\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.7-bin.jar
文件 375 2009-07-12 14:35 testMySQL\WebRoot\WEB-INF\web.xm
文件 844 2009-07-12 14:55 testMySQL\WebRoot\welcome.jsp
目录 0 2009-07-13 10:58 testMySQL\WebRoot\WEB-INF\classes\com
目录 0 2009-07-13 10:58 testMySQL\WebRoot\WEB-INF\classes
目录 0 2009-07-13 10:58 testMySQL\WebRoot\WEB-INF\lib
目录 0 2009-07-13 10:58 testMySQL\src\com
目录 0 2009-07-13 10:58 testMySQL\WebRoot\me
目录 0 2009-07-13 10:58 testMySQL\WebRoot\WEB-INF
目录 0 2009-07-13 10:58 testMySQL\.myeclipse
目录 0 2009-07-13 10:58 testMySQL\.settings
目录 0 2009-07-13 10:58 testMySQL\src
目录 0 2009-07-13 10:58 testMySQL\WebRoot
目录 0 2009-07-13 10:58 testMySQL
----------- --------- ---------- ----- ----
732376 27
............此处省略0个文件信息
- 上一篇:android购书系统
- 下一篇:操作系统实验及其代码Java编写
相关资源
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- JSP,SQL,MVC的选课系统
- 基于JSP的学生宿舍管理系统(源码 数
- JSP选课管理系统
- mysql jsp网站源码下载
- JSP做的化妆品商城
- Jsp购物车实例
- 基于JSP的校友信息管理系统(添加数
- 基于jsp的bbs论坛 非常详细
- jsp oracle通讯录
- JSP学生信息管理系统 Mysql数据库
- 使用jsp servlet做的投票系统
- android通过JDBC连接Mysql数据库
- JSP登陆验证 实现JSP用户名 密码 验
- jsp基于servlet 图书馆管理系统
- jsp学生成绩管理系统.rar
- 在线考试系统源代码(jsp)
- 超级好的纯jsp写的聊天室
- JSP 网上购物网页项目
- JSP+mysql新闻发布系统.rar
- jsp 学生信息管理系统设计与实现
- java实现的QQ登录界面
- jsp与SQL Server数据库实现的客户注册登
- 简易教学管理系统(jsp spring struts h
- 学生信息管理系统 JSP MySQL
- jsp ajax 三级联动菜单
- jsp新闻公告与最新消息系统(具备添
- JSP课程设计-留言本 jsp mysql tomcat实现
- jsp 做的 班级管理网站
川公网安备 51152502000135号
评论
共有 条评论