资源简介
供初学者学习JDBC+Swing使用,内有详细说明文件,请读者下载后了解。
代码片段和文件信息
package com.neusoft.dao;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import com.neusoft.jdbcUtil.SingletonUtil;
public abstract class AbstractDao {
public Listject> find(String sqlobject[] args) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
Listject> list = new ArrayListject>();
try{
connection = SingletonUtil.getSingletonUtil().getConnction();
ps = connection.prepareStatement(sql);
for(int i=0; i ps.setobject(i+1 args[i]);
}
rs = ps.executeQuery();
object obj = null;
while(rs.next()) {
obj = rowMapper(rs);//交给继承的类自己实现其所需求的rowMapper()
list.add(obj);
}
return list;
} catch(SQLException e) {
throw new DaoException(e.getMessage() e);
} finally {
SingletonUtil.getSingletonUtil().freeConn(rs ps connection);
}
}
abstract protected object rowMapper(ResultSet rs) throws SQLException;
public int modify(String sql object[] args) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
//this.find(sql args);
try{
connection = SingletonUtil.getSingletonUtil().getConnction();
ps = connection.prepareStatement(sql);
for(int i=0; i ps.setobject(i+1 args[i]);
}
return ps.executeUpdate();
} catch(SQLException e) {
throw new DaoException(e.getMessage()e);
} finally {
SingletonUtil.getSingletonUtil().freeConn(rs ps connection);
}
}
public void add(String sql object[] args) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
connection = SingletonUtil.getSingletonUtil().getConnction();
ps = connection.prepareStatement(sql);
for(int i=0; i ps.setobject(i+1 args[i]);
}
ps.executeUpdate();
} catch(SQLException e) {
throw new DaoException(e.getMessage()e);
//e.printStackTrace();
} finally{
SingletonUtil.getSingletonUtil().freeConn(rs ps connection);
}
}
public int delete(String sql object args[]) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
connection = SingletonUtil.getSingletonUtil().getConnction();
ps = connection.prepareStatement(sql);
for(int i=0; i ps.setobject(i+1 args[i]);
}
return ps.executeUpdate();
} catch(SQLException e) {
throw new DaoException(e.getMessage()e);
} finally {
SingletonUtil.getSingletonUtil().freeConn(rs ps connection);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-06-01 18:43 swing+jdbc学生选课系统\
文件 537303 2010-04-19 10:12 swing+jdbc学生选课系统\sqljdbc4.jar
文件 2149 2011-05-07 17:39 swing+jdbc学生选课系统\student.sql
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\
文件 387 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\.classpath
文件 389 2011-05-06 20:30 swing+jdbc学生选课系统\StudentManage\.project
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\
文件 3168 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\AbstractDao.class
文件 799 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\DaoException.class
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\impl\
文件 3797 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\impl\CourseDaoImpl.class
文件 1782 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\impl\LoginDaoImpl.class
文件 3697 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\impl\SelectDaoImpl.class
文件 3563 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\dao\impl\UserDaoImpl.class
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\domain\
文件 1391 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\domain\CourseInfo.class
文件 982 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\domain\SelectedInfo.class
文件 1158 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\domain\UserInfo.class
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
文件 4068 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
文件 2516 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
文件 3322 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
文件 3790 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
文件 4319 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
文件 4156 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
目录 0 2011-06-01 18:42 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
文件 3631 2011-05-26 08:02 swing+jdbc学生选课系统\StudentManage\bin\com\neusoft\fr
............此处省略61个文件信息
- 上一篇:t9Input-stm32
- 下一篇:BMFont位图制作工具
评论
共有 条评论