自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(0)
  • 资源 (15)
  • 收藏
  • 关注

空空如也

安卓系统安装和学习文档

意思就是我们现在下载的只是基本的 SDK工具,并不是真正可以使用的SDK 我们运行 SDK Manager.exe 就会自动从官方下载最新的 SDK了 ,不过如果要完全下载下来, 用国内的网络估计不是一件容易的事情。这要怪google和中国政府的关系不好,服务器不在咱家里啊! 这里我给个链接,可以直接用迅雷下载,已经有比较完整的SDK版本了.

2012-05-18

C#泛型集合

轻松学会C#泛型集合,代码简洁清楚明了,让初学者一看就懂

2012-05-04

C#Windows服务

初学者必看,轻松学会C#Windows服务

2012-05-04

C#序列化的使用

C#序列化的使用,有操作全过程,还有联系题,轻松学会序列化

2012-05-04

C#文件流的使用

初学C#必看,简单轻松学会文件流,有导入,导出功能

2012-05-04

C#自定义控件的使用

C#自定义控件的使用,轻松学会自定义控件

2012-05-04

C#打印控件的使用

C#打印控件的使用,轻松学会打印控件的使用

2012-05-04

C#程序与存储过程

C#程序与存储过程,用存储过程来实现复杂业务

2012-05-04

C#代码编写的简易计算器

C#代码编写的简易计算器,可进行数字的加减剩除

2012-05-04

关于项目发布过程

C#窗体程序和.net网站的发布有截图说明,清楚明了

2012-05-04

学生考试系统

• 当代信息技术发展迅速,各大高校学生逐渐增加,学校管理压力加大,考试繁杂,所以仅需开发学生考试系统用于学生需要。

2012-04-24

图书馆管理系统

管理员,借书人(学生),老师,图书工作员工。 管理员: 维护图书管系统。解决图书管理系统的所有技术问题。 学生:可以借阅图书,还书。借书时间1个月,数量3本。 老师:可以借阅图书,还书,借书有优惠,比如时间长点2个月,数量多点5本。 工作员工:负责图书管理系统的日常操作,借书,还书,续集,会员申请等日常工作。

2012-04-24

超市管理系统

库存管理是指在物流过程中商品数量的管理。过去认为仓库里的商品多,表明企业发达、兴隆,现在则认为 零库存是最好的库存管理。库存多,占用资金多,利息负担加重。但是如果过份降低库存,则会出现断档。

2012-04-24

DButil.java

package com.parddu.dao; import java.io.IOException; import java.sql.*; import java.util.Properties; /** * 数据库功能类 * @author parddu * @version Sep 29, 2010 9:49:31 AM */ class DButil { private String driver=null; //驱动 private String dbName=null; //数据库名 private String host=null; //主机名 private String point=null; //端口 private String userName=null; //登录帐号 private String userPass=null; //登录密码 private static DButil info = null; private DButil(){} /** * 初始化方法,加载数据库连接信息 * @throws IOException */ private static void init() throws IOException{ Properties prop = new Properties(); prop.load(DButil.class.getResourceAsStream("/db_config.properties")); info = new DButil(); info.driver = prop.getProperty("driver"); info.dbName = prop.getProperty("dbName"); info.host = prop.getProperty("host"); info.point = prop.getProperty("point"); info.userName = prop.getProperty("userName"); info.userPass = prop.getProperty("userPass"); } /** * 得到数据库连接对象 * @return 数据库连接对象 */ static Connection getConn(){ Connection conn=null; if(info == null){ try { init(); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } } if(info!=null){ try { Class.forName(info.driver); String url="jdbc:sqlserver://" + info.host + ":" + info.point + ";databaseName=" + info.dbName; conn=DriverManager.getConnection(url,info.userName,info.userPass); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } else{ throw new RuntimeException("读取数据库配置信息异常!"); } return conn; } /** * 关闭查询数据库访问对象 * @param rs 结果集 * @param st 上下文 * @param conn 连接对象 */ static void closeConn(ResultSet rs, Statement st,Connection conn){ try { rs.close(); } catch (Exception e) {} try { st.close(); } catch (Exception e) {} try { conn.close(); } catch (Exception e) {} } /** * 关闭增、删、该数据库访问对象 * @param st 上下文对象 * @param conn 连接对象 */ static void closeConn(Statement st ,Connection conn){ try{ st.close(); conn.close(); }catch(Exception e){} } }

2012-04-24

java万能DAO

所有业务逻辑类皆可调用该类 package com.parddu.dao; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * 通用DAO类 * @author parddu * @version Sep 29, 2010 10:16:23 AM */ public class CommonDAO { /** * 修改数据 * @param sql sql语句 * @param param 参数列表 * @return 修改记录行数 */ public int update(String sql,List param){ int row = -1; Connection conn = null; PreparedStatement update = null; try { conn = DButil.getConn(); update = conn.prepareStatement(sql); this.setParam(update, param); row = update.executeUpdate(); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } finally{ DButil.closeConn(update, conn); } return row; } /** * 查询数据 * @param sql sql语句 * @param param 参数 * @return 结果集HashMap<列名,值对象> */ public List<HashMap> query(String sql,List param) { List<HashMap> list = new ArrayList<HashMap>(); Connection conn = null; PreparedStatement query = null; ResultSet rs = null; try { conn = DButil.getConn(); query = conn.prepareStatement(sql); this.setParam(query, param); rs = query.executeQuery(); if(rs!=null){ //取得所有的列名 ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); String[] columnNameArray = new String[columnCount]; for(int i=0;i<columnCount;i++){ columnNameArray[i] = rsmd.getColumnName(i+1); } //读取结果 while(rs.next()){ HashMap<String,Object> hm = new HashMap<String,Object>(); for(String cn : columnNameArray){ hm.put(cn, rs.getObject(cn)); } list.add(hm); } } } catch (Exception e) { throw new RuntimeException(e.getMessage()); } finally{ DButil.closeConn(rs,query, conn); } return list; } /** * 查询数据 * @param sql sql语句 * @param param 参数 * @return 结果集List<实体对象> */ public List query(String sql,List param,Class cla){ List list = new ArrayList(); Connection conn = null; PreparedStatement query = null; ResultSet rs = null; try { conn = DButil.getConn(); query = conn.prepareStatement(sql); this.setParam(query, param); rs = query.executeQuery(); if(rs!=null){ //取得所有的列名 ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); String[] columnNameArray = new String[columnCount]; for(int i=0;i<columnCount;i++){ columnNameArray[i] = rsmd.getColumnName(i+1); } //得到所有列和方法匹配的项 List<PropertyMthod> mList = new ArrayList<PropertyMthod>(); for(String columnName : columnNameArray){ Method m = this.getMethod(cla,columnName); if(m!=null){ PropertyMthod pm = new PropertyMthod(m,columnName); mList.add(pm); } } //读取结果 while(rs.next()){ Object o = cla.newInstance(); for(PropertyMthod pm : mList){ this.invokeSetMethod(o, pm.getMethod(), rs, pm.getColumn()); } list.add(o); } } } catch (Exception e) { throw new RuntimeException(e.getMessage()); } finally{ DButil.closeConn(rs,query, conn); } return list; } /** * 调用目标对象的set方法 * @param o 目标对象 * @param m set方法 * @param rs 结果集 * @param columnName 列名 * @throws SecurityException * @throws NoSuchMethodException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException */ private void invokeSetMethod(Object o,Method m,ResultSet rs,String columnName) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{ String paramType = m.getParameterTypes()[0].getName(); paramType = paramType.substring(paramType.lastIndexOf(".")+1); /*****特殊类型处理******/ if("Integer".equals(paramType)){ paramType = "Int"; } String strName = "get" + this.firstUpper(paramType); Method rsMethod = rs.getClass().getDeclaredMethod(strName, String.class); m.invoke(o, rsMethod.invoke(rs, columnName)); } /** * 匹配指定列名的set方法 * @param o * @param column * @return * @throws NoSuchMethodException * @throws SecurityException */ private Method getMethod(Class o,String column) throws SecurityException, NoSuchMethodException{ Method m = null; List<String> strList = new ArrayList<String>(); /********set方法转换设置***********/ strList.add(column); //去掉下划线stu_name---&gt;stuName strList.add(this.delLine(column,"_")); boolean flage = false; Method[] mlist = o.getDeclaredMethods(); for(Method tempm : mlist){ for(String s:strList){ String name = "set"+this.firstUpper(s); if(tempm.getName().equals(name)){ m=tempm; flage = true; break; } } if(flage){ break; } } if(!flage){ System.out.println("查询列名" + column + "在实体中无方法名匹配,值将不会被设置!"); } return m; } /** * 删除列分割符 * @return */ private String delLine(String str,String fg){ String result = str; if(str.indexOf(fg)!=-1){ result = str.substring(0,str.indexOf(fg))+ this.firstUpper(str.substring(str.indexOf(fg)+1)); result = delLine(result,fg); } return result; } /** * 将给定字符串首字母修改为小写 * @param str 字符串 * @return 转换后的字符串 */ private String firstUpper(String str){ return (str.charAt(0)+"").toUpperCase()+str.substring(1); } /** * 设置参数 * @param ps 预编译对象 * @param param 参数集合 * @throws SQLException */ private void setParam(PreparedStatement ps,List param) throws SQLException{ if(param!=null&&param;.size()>0){ for(int i=0;i<param.size();i++){ ps.setObject(i+1, param.get(i)); } } } }

2012-04-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除