java数据库通用操作类.doc
还剩
15页未读,
继续阅读
下载文档到电脑,马上远离加班熬夜!
亲,喜欢就下载吧,价低环保!
内容要点:
package com.hospital.dao.tools; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java. private static String _DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; @SuppressWarnings("unused") private static String _URL = "jdbc:sqlserver://localhost:1433;database=Hospital_AI_DB;ch try { con.setAutoCommit(false); } catch (SQLException e) { e.printStackTrace(); } } /** * 从指定参数得到一个连接对象 * * @param driver * @param url * @param user_na * @param password * @throws Exception ******************************************************************************************* *//** * **************************************** 数据库操作方法 * *********************************** *//** ******** * 执行 SQL语句操作(更新数据 有参数) * * @param strSql * sql指令 * @param prams * 参数列表 * @return * @throws SQLException */public boolean executeUpdate(String strSql, HashMap prams) throws } /** * 执行 SQL语句操作(查询数据 无参数) * * @param strSql * SQL语句 * @return 数组对象列表 * @throws Exception */public ArrayList> executeSql(String strSql) throws Exception { getConnection(); // getConn logger.info("###############::执行 SQL语句操作(查询数据):" + strSql); rs = pstmt.executeQuery(); con.commit(); if (null != rs) { return convertResultSetToArrayList(rs); } return null; } /** * 执行存储过程(查询数 */public ArrayList> executeProcedureQuery( String procName, Object[] parameters) throws Exception { int parameterPoint = 0; // 获取存储过程信息
发表评论
暂无评论,赶快抢占沙发吧。