资源简介
这是一个用javaweb写的评教系统,很小项目,代码分层清晰易懂规范,适合初学者拿来练手学习,包含数据库
代码片段和文件信息
package dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class baseDAO {
public baseDAO() {
try {
Class.forName(“com.mysql.jdbc.Driver“);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
// 属性 --------------------------
private Connection conn;
private Statement stm;
private PreparedStatement pstm;
private ResultSet rs;
// 获得连接--------------------------
public Connection getConn() {
try {
if (conn == null || conn.isClosed()) {
conn = DriverManager.getConnection(
“jdbc:mysql://localhost:3306/judge_teacher“
“root“ “root“);
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println(“getConnection()错误“);
}
return conn;
}
// 执行增、删、改SQL语句--------------------
public int executeUpdate(String sql) throws SQLException {
if (getConn() == null) {
System.out.println(“与数据库连接失败!“);
return -1;
}
stm = conn.createStatement();
return stm.executeUpdate(sql);
}
// 重载执行增、删、改SQL语句--------------------
public int executeUpdate(String sql object[] obj) throws SQLException {
if (getConn() == null) {
System.out.println(“与数据库连接失败!“);
return -1;
}
pstm = conn.prepareStatement(sql);
if (obj != null) {
for (int i = 0; i < obj.length; i++) {
pstm.setobject(i + 1 obj[i]);
}
}
return pstm.executeUpdate();
}
// 执行查询SQL语句----------------------------
public ResultSet executeQuery(String sql) throws SQLException {
if (getConn() == null) {
System.out.println(“与数据库连接失败!“);
return null;
}
stm = conn.createStatement();
rs = stm.executeQuery(sql);
return rs;
}
// 重载执行查询SQL语句----------------------------
public ResultSet executeQuery(String sql object[] obj) throws SQLException {
if (getConn() == null) {
System.out.println(“与数据库连接失败!“);
return null;
}
pstm = conn.prepareStatement(sql);
if (obj != null) {
for (int i = 0; i < obj.length; i++) {
pstm.setobject(i + 1 obj[i]);
}
}
rs = pstm.executeQuery();
return rs;
}
// 关闭ResultSet
public void closeResultSet() {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
// 关闭Connection
public void closeConnection() {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
// 关闭Statement和PreparedStatement
public void closeStatement() {
if (stm != null) {
try {
stm.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (pstm != null) {
try {
pstm.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1871179 2018-06-14 15:37 mysql.docx
文件 74752 2013-02-23 16:53 phpStudy\Apache\bin\ab.exe
文件 79360 2013-02-23 16:50 phpStudy\Apache\bin\abs.exe
文件 33280 2013-02-23 16:49 phpStudy\Apache\bin\ApacheMonitor.exe
文件 13824 2013-02-21 20:14 phpStudy\Apache\bin\apr_crypto_openssl-1.dll
文件 18944 2013-02-21 20:16 phpStudy\Apache\bin\apr_dbd_mysql-1.dll
文件 22016 2013-02-23 16:50 phpStudy\Apache\bin\apr_dbd_odbc-1.dll
文件 12288 2013-02-23 16:48 phpStudy\Apache\bin\apr_ldap-1.dll
文件 9192 2013-02-23 16:54 phpStudy\Apache\bin\dbmmanage.pl
文件 82432 2013-02-23 16:48 phpStudy\Apache\bin\htcacheclean.exe
文件 83968 2013-02-23 16:53 phpStudy\Apache\bin\htdbm.exe
文件 67584 2013-02-23 16:48 phpStudy\Apache\bin\htdigest.exe
文件 78848 2013-02-23 16:49 phpStudy\Apache\bin\htpasswd.exe
文件 20992 2013-02-23 16:49 phpStudy\Apache\bin\httpd.exe
文件 53760 2013-02-23 16:49 phpStudy\Apache\bin\httxt2dbm.exe
文件 133632 2013-02-23 16:46 phpStudy\Apache\bin\libapr-1.dll
文件 27136 2013-02-23 16:46 phpStudy\Apache\bin\libapriconv-1.dll
文件 184320 2013-02-23 16:46 phpStudy\Apache\bin\libaprutil-1.dll
文件 1058816 2013-02-23 14:57 phpStudy\Apache\bin\libeay32.dll
文件 312832 2013-02-23 16:46 phpStudy\Apache\bin\libhttpd.dll
文件 1017344 2012-12-27 12:13 phpStudy\Apache\bin\libxm
文件 48640 2013-02-23 16:49 phpStudy\Apache\bin\logresolve.exe
文件 122880 2012-04-07 11:36 phpStudy\Apache\bin\lua51.dll
文件 327168 2013-02-23 14:58 phpStudy\Apache\bin\openssl.exe
文件 112128 2012-12-27 12:10 phpStudy\Apache\bin\pcre.dll
文件 64000 2013-02-23 16:49 phpStudy\Apache\bin\rotatelogs.exe
文件 215040 2013-02-23 14:57 phpStudy\Apache\bin\ssleay32.dll
文件 13312 2013-02-23 16:49 phpStudy\Apache\bin\wintty.exe
文件 67584 2012-05-14 11:33 phpStudy\Apache\bin\zlib1.dll
文件 880 2013-02-23 16:29 phpStudy\Apache\cgi-bin\printenv.pl
............此处省略874个文件信息
- 上一篇:基于Android的商城APP.rar
- 下一篇:学生选课系统源码
评论
共有 条评论