- 浏览: 153876 次
- 性别:
- 来自: 贵州
文章分类
- 全部博客 (149)
- 从业生涯 (10)
- 杂草集 (4)
- 数据库方案 (18)
- VIew层 (1)
- 学习 (10)
- IDE (4)
- JavaScript (10)
- 中间件 (16)
- DWR (4)
- 正则表达式 (2)
- JAVA (10)
- SQL (2)
- 数据结构 (6)
- Spring Security (0)
- JQuery (3)
- JSP (2)
- SEO (1)
- JspRun (1)
- 搜索引擎 (1)
- 信息检索 (5)
- Eclipse (1)
- 日志 (3)
- apache (1)
- Dos (1)
- 标签库 (1)
- 项目管理 (3)
- JSON (2)
- UML (1)
- 职业规划 (5)
- 标准 (1)
- OS (6)
- flash (1)
- 安全 (1)
- 负载均衡 (3)
- jndi (1)
- linux (1)
- bat (1)
- git (2)
- 树莓派 (1)
- Shell (1)
最新评论
-
qingmuxiang:
学无止境
通用数据库分页 扩展dbutil (附代码下载) -
haiyangyiba:
你好,下载了你的例子,主要看了如下方法:public < ...
通用数据库分页 扩展dbutil (附代码下载)
package thtf.ebuilder.db; import java.sql.Connection; import java.sql.DriverManager; import java.util.ArrayList; import java.util.Map; import javax.naming.InitialContext; import javax.sql.DataSource; import org.apache.commons.dbutils.DbUtils; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.ResultSetHandler; import org.apache.commons.dbutils.handlers.ArrayHandler; import org.apache.commons.dbutils.handlers.ArrayListHandler; import org.apache.commons.dbutils.handlers.BeanHandler; import org.apache.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.MapHandler; import org.apache.commons.dbutils.handlers.MapListHandler; /** * 采用Apache dbutils操作数据库的工具类,可采用Spring注入DataSource * * <pre> * 方式一:使用默认的数据源(jdbc/eBuilder) * DBUtil tool=new DBUtil();///操作完毕默认关闭连接 * DBUtil tool=new DBUtil(false);//设置不关闭连接 * 使用完之后关闭连接 tool.close(); * 方式二:使用自定义数据源 * String dataSourceName=""; * DBUtil tool=new DBUtil(dataSourceName);///操作完毕默认关闭连接 * DBUtil tool=new DBUtil(dataSourceName,false);//操作完毕不关闭连接 * 使用完之后关闭连接 tool.close(); * 方式三:使用自定义数据源 * java.sql.DataSource dataSource=null; * DBUtil tool=new DBUtil(dataSource);///操作完毕默认关闭连接 * DBUtil tool=new DBUtil(dataSource,false);//操作完毕不关闭连接 * 使用完之后关闭连接 tool.close(); * 方式四:使用指定的数据库连接 * java.sql.connection=null; * DBUtil tool=new DBUtil(connection);///操作完毕默认关闭连接 * DBUtil tool=new DBUtil(dataSource,false);//操作完毕不关闭连接 * 使用完之后关闭连接 tool.close(); * </pre> * * @author 杨伦亮 Jun 13, 2011 */ public class DBUtil { // Spring可注入DataSource public DataSource dataSource = null; private Connection connection = null; // ***********静态变量 private boolean CloseConnection = true; public static final String DEFAULT_JNDI = "jdbc/eBuilder"; /** * 采用默认数据库连接(jdbc/eBuilder)操作完毕默认关闭连接 */ public DBUtil() { } /** * 采用默认数据库连接(jdbc/eBuilder)可指定是否操作完毕关闭连接 */ public DBUtil(boolean closeConnection) { CloseConnection = closeConnection; } /** * 采用指定的数据库连接,操作完毕默认关闭连接 * * @param connection */ public DBUtil(Connection connection) { this.connection = connection; } /** * 采用指定的数据库连接,可指定是否操作完毕关闭连接 * * @param connection * @param closeConnection */ public DBUtil(Connection connection, boolean closeConnection) { this.connection = connection; CloseConnection = closeConnection; } /** * 采用指定的DataSource操作数据库,操作完毕默认关闭连接 * * @param dataSource */ public DBUtil(DataSource dataSource) { try { this.dataSource = dataSource; } catch (Exception e) { e.printStackTrace(); } } /** * 采用指定的DataSource操作数据库,可指定是否操作完毕关闭连接 * * @param dataSource * @param closeConnection */ public DBUtil(DataSource dataSource, boolean closeConnection) { try { this.dataSource = dataSource; CloseConnection = closeConnection; } catch (Exception e) { e.printStackTrace(); } } /** * Execute a batch of SQL INSERT, UPDATE, or DELETE queries. * * @param sql * The SQL to execute. * @param params * An array of query replacement parameters. Each row in this * array is one set of batch replacement values. * @return The number of rows updated per statement. */ @SuppressWarnings({"unchecked", "deprecation"}) public int[] batch(String sql, Object[][] params) throws Exception { Connection conn = this.getConnection(); int[] rows = null; QueryRunner run = new QueryRunner(); try { rows = run.batch(conn, sql, params); } finally { close(conn); } return rows; } /** * 关闭连接 * * @param connection */ public void close() { DbUtils.closeQuietly(connection); } private void close(Connection connection){ if(CloseConnection){ DbUtils.closeQuietly(connection); } } /** * Executes the given INSERT, UPDATE, or DELETE SQL statement without any * replacement parameters. * * @param sql * The SQL statement to execute. * @return The number of rows updated. */ @SuppressWarnings({"unchecked", "deprecation"}) public int executeUpdate(String sql) throws Exception { Connection conn = this.getConnection(); int rows = 0; QueryRunner run = new QueryRunner(); try { rows = run.update(conn, sql); } finally { close(conn); } return rows; } /** * Executes the given INSERT, UPDATE, or DELETE SQL statement with a single * replacement parameter. * * @param sql * The SQL statement to execute. * @param param * The replacement parameter. * @return The number of rows updated. */ @SuppressWarnings({"unchecked", "deprecation"}) public int executeUpdate(String sql, Object param) throws Exception { Connection conn = this.getConnection(); int rows = 0; QueryRunner run = new QueryRunner(); try { rows = run.update(conn, sql, param); } finally { close(conn); } return rows; } /** * Executes the given INSERT, UPDATE, or DELETE SQL statement. * * @param sql * The SQL statement to execute. * @param params * Initializes the PreparedStatement's IN (i.e. '?') parameters. * @return The number of rows updated. */ @SuppressWarnings({"unchecked", "deprecation"}) public int executeUpdate(String sql, Object[] params) throws Exception { Connection conn = this.getConnection(); int rows = 0; QueryRunner run = new QueryRunner(); try { rows = run.update(conn, sql, params); } finally { close(conn); } return rows; } /** * 获得数据库的连接 * * @return Connection */ public Connection getConnection() throws Exception { // 如果Connection为空 Class.forName("net.sourceforge.jtds.jdbc.Driver"); connection = DriverManager .getConnection( "jdbc:jtds:sqlserver://localhost:1433;DatabaseName=website;useLOBs=false", "sa", "sa1"); if (connection == null || connection.isClosed()) { // 如果dataSource没有注入就采用默认的 if (dataSource == null) { dataSource = (DataSource) new InitialContext() .lookup(DEFAULT_JNDI); } connection = dataSource.getConnection(); } return connection; } public DataSource getDataSource() { return dataSource; } /** * Get Maximun Field Value Named 'sFldName' of Table 'sTblName' * * @param sTblName * The Table Name * @param sFldName * The Field Name * @return Maximum Id */ @SuppressWarnings({"unchecked", "deprecation"}) public int getMaxId(String sTableName, String sFieldName) { int iRes = -1; String sql = "SELECT MAX(" + sFieldName + ") AS maxid FROM " + sTableName; Map result; try { result = queryToMap(sql); if (result.get("maxid") != null) { iRes = Integer.parseInt(result.get("maxid").toString()) + 1; } } catch (Exception e) { e.printStackTrace(); } return iRes; } /** * Execute an SQL SELECT query without any replacement parameters and place * the column values from the first row in an Object[]. Usage Demo: * * <pre> * Object[] result = searchToArray(sql); * if (result != null) { * for (int i = 0; i < result.length; i++) { * System.out.println(result[i]); * } * } * </pre> * * @param sql * The SQL to execute. * @return An Object[] or null if there are no rows in the ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Object[] queryToArray(String sql) throws Exception { Connection conn = this.getConnection(); Object[] result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new ArrayHandler(); try { result = (Object[]) run.query(conn, sql, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL with a single replacement parameter and * place the column values from the first row in an Object[]. * * @param sql * The SQL statement to execute. * @param param * The replacement parameter. * @return An Object[] or null if there are no rows in the ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Object[] queryToArray(String sql, Object param) throws Exception { Connection conn = this.getConnection(); Object[] result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new ArrayHandler(); try { result = (Object[]) run.query(conn, sql, param, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL query and place the column values from the * first row in an Object[]. * * @param sql * The SQL statement to execute. * @param params * Initialize the PreparedStatement's IN parameters with this * array. * @return An Object[] or null if there are no rows in the ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Object[] queryToArray(String sql, Object[] params) throws Exception { Connection conn = this.getConnection(); Object[] result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new ArrayHandler(); try { result = (Object[]) run.query(conn, sql, params, h); } finally { close(conn); } return result; } /** * Execute an SQL SELECT query without any replacement parameters and place * the ResultSet into a List of Object[]s Usage Demo: * * <pre> * ArrayList result = queryToArrayList(sql); * Iterator iterator = result.iterator(); * while (iterator.hasNext()) { * Object[] temp = (Object[]) iterator.next(); * for (int i = 0; i < temp.length; i++) { * System.out.println(temp[i]); * } * } * </pre> * * @param sql * The SQL statement to execute. * @return A List of Object[]s, never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToArrayList(String sql) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new ArrayListHandler(); try { result = (ArrayList) run.query(conn, sql, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL with a single replacement parameter and * place the ResultSet into a List of Object[]s * * @param sql * The SQL statement to execute. * @param param * The replacement parameter. * @return A List of Object[]s, never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToArrayList(String sql, Object param) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new ArrayListHandler(); try { result = (ArrayList) run.query(conn, sql, param, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL query and place the ResultSet into a List * of Object[]s * * @param sql * The SQL statement to execute. * @param params * Initialize the PreparedStatement's IN parameters with this * array. * @return A List of Object[]s, never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToArrayList(String sql, Object[] params) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new ArrayListHandler(); try { result = (ArrayList) run.query(conn, sql, params, h); } finally { close(conn); } return result; } /** * Execute an SQL SELECT query without any replacement parameters and * converts the first ResultSet into a Map object. Usage Demo: * * <pre> * Map result = queryToMap(sql); * System.out.println(map.get(columnName)); * </pre> * * @param sql * The SQL to execute. * @return A Map with the values from the first row or null if there are no * rows in the ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Map queryToMap(String sql) throws Exception { Connection conn = this.getConnection(); Map result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new MapHandler(); try { result = (Map) run.query(conn, sql, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL with a single replacement parameter and * converts the first ResultSet into a Map object. * * @param sql * The SQL to execute. * @param param * The replacement parameter. * @return A Map with the values from the first row or null if there are no * rows in the ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Map queryToMap(String sql, Object param) throws Exception { Connection conn = this.getConnection(); Map result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new MapHandler(); try { result = (Map) run.query(conn, sql, param, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL query and converts the first ResultSet into * a Map object. * * @param sql * The SQL to execute. * @param params * Initialize the PreparedStatement's IN parameters with this * array. * @return A Map with the values from the first row or null if there are no * rows in the ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Map queryToMap(String sql, Object[] params) throws Exception { Connection conn = this.getConnection(); Map result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new MapHandler(); try { result = (Map) run.query(conn, sql, params, h); } finally { close(conn); } return result; } /** * Execute an SQL SELECT query without any replacement parameters and * converts the ResultSet into a List of Map objects. Usage Demo: * * <pre> * ArrayList result = queryToMapList(sql); * Iterator iterator = result.iterator(); * while (iterator.hasNext()) { * Map map = (Map) iterator.next(); * System.out.println(map.get(columnName)); * } * </pre> * * @param sql * The SQL to execute. * @return A List of Maps, never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToMapList(String sql) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new MapListHandler(); try { result = (ArrayList) run.query(conn, sql, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL with a single replacement parameter and * converts the ResultSet into a List of Map objects. * * @param sql * The SQL to execute. * @param param * The replacement parameter. * @return A List of Maps, never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToMapList(String sql, Object param) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new MapListHandler(); try { result = (ArrayList) run.query(conn, sql, param, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL query and converts the ResultSet into a * List of Map objects. * * @param sql * The SQL to execute. * @param params * Initialize the PreparedStatement's IN parameters with this * array. * @return A List of Maps, never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToMapList(String sql, Object[] params) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new MapListHandler(); try { result = (ArrayList) run.query(conn, sql, params, h); } finally { close(conn); } return result; } /** * Execute an SQL SELECT query without any replacement parameters and * Convert the first row of the ResultSet into a bean with the Class given * in the parameter. Usage Demo: * * <pre> * String sql = "SELECT * FROM test"; * Test test = (Test) queryToBean(Test.class, sql); * if (test != null) { * System.out.println("test:" + test.getPropertyName()); * } * </pre> * * @param type * The Class of beans. * @param sql * The SQL to execute. * @return An initialized JavaBean or null if there were no rows in the * ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Object queryToBean(Class type, String sql) throws Exception { Connection conn = this.getConnection(); Object result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new BeanHandler(type); try { result = run.query(conn, sql, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL with a single replacement parameter and * Convert the first row of the ResultSet into a bean with the Class given * in the parameter. * * @param type * The Class of beans. * @param sql * The SQL to execute. * @param param * The replacement parameter. * @return An initialized JavaBean or null if there were no rows in the * ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Object queryToBean(Class type, String sql, Object param) throws Exception { Connection conn = this.getConnection(); Object result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new BeanHandler(type); try { result = run.query(conn, sql, param, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL query and Convert the first row of the * ResultSet into a bean with the Class given in the parameter. * * @param type * The Class of beans. * @param sql * The SQL to execute. * @param params * Initialize the PreparedStatement's IN parameters with this * array. * @return An initialized JavaBean or null if there were no rows in the * ResultSet. */ @SuppressWarnings({"unchecked", "deprecation"}) public Object queryToBean(Class type, String sql, Object[] params) throws Exception { Connection conn = this.getConnection(); Object result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new BeanHandler(type); try { result = run.query(conn, sql, params, h); } finally { close(conn); } return result; } /** * Execute an SQL SELECT query without any replacement parameters and * Convert the ResultSet rows into a List of beans with the Class given in * the parameter. Usage Demo: * * <pre> * ArrayList result = queryToBeanList(Test.class, sql); * Iterator iterator = result.iterator(); * while (iterator.hasNext()) { * Test test = (Test) iterator.next(); * System.out.println(test.getPropertyName()); * } * </pre> * * @param type * The Class that objects returned from handle() are created * from. * @param sql * The SQL to execute. * @return A List of beans (one for each row), never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToBeanList(Class type, String sql) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new BeanListHandler(type); try { result = (ArrayList) run.query(conn, sql, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL with a single replacement parameter and * Convert the ResultSet rows into a List of beans with the Class given in * the parameter. * * @param type * The Class that objects returned from handle() are created * from. * @param sql * The SQL to execute. * @param param * The replacement parameter. * @return A List of beans (one for each row), never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToBeanList(Class type, String sql, Object param) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new BeanListHandler(type); try { result = (ArrayList) run.query(conn, sql, param, h); } finally { close(conn); } return result; } /** * Executes the given SELECT SQL query and Convert the ResultSet rows into a * List of beans with the Class given in the parameter. * * @param type * The Class that objects returned from handle() are created * from. * @param sql * The SQL to execute. * @param params * Initialize the PreparedStatement's IN parameters with this * array. * @return A List of beans (one for each row), never null. */ @SuppressWarnings({"unchecked", "deprecation"}) public ArrayList queryToBeanList(Class type, String sql, Object[] params) throws Exception { Connection conn = this.getConnection(); ArrayList result = null; QueryRunner run = new QueryRunner(); ResultSetHandler h = new BeanListHandler(type); try { result = (ArrayList) run.query(conn, sql, params, h); } finally { close(conn); } return result; } /** * 回滚事务关关闭连接 * * @param connection */ public static void rolbackAndClose(Connection connection) { try { DbUtils.rollbackAndClose(connection); } catch (Exception e) { } } public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } public static void main(String[] args) { Connection connection=null; try{ DBUtil tool=new DBUtil(false); connection=tool.getConnection(); System.out.println("step1:连接是否已经获得?"); System.out.println(((connection!=null)||(!connection.isClosed()))); System.out.println("\nstep2:尝试关闭本地连接...\nconnection.close();"); connection.close(); System.out.println("\nstep3:本地连接是否关闭?\t"+(connection.isClosed())); System.out.println("DBUtil中的连接是否关闭?\t"); tool.conncectionState(); System.out.println("\nstep4:关闭本地连接之后,DBUtil中的连接是否关闭?"); tool.conncectionState(); }catch (Exception e) { e.printStackTrace(); }finally{ try{ if(connection!=null){ connection.close(); } }catch (Exception e) { } System.out.println("\nstep5:测试数据库连接完毕!"); } } public void conncectionState() { try{ System.out.println("连接是否为空:\t"+(connection==null)); System.out.println("连接是否关闭:\t"+(connection.isClosed())); }catch (Exception e) { } } }
发表评论
-
Mysql安装
2015-10-18 22:18 503最近要配置一些项目管理工具,要用到MYSQL于是就想去下个 ... -
SqlServer2005 上安装 SqlServer2008 JTDS连接
2015-02-05 23:05 658SQLServer2008不能直接升级安装SQLServer ... -
Mysql 连接池与线程太小的设置
2015-01-26 02:09 590my.ini thread_cache_size=1 ... -
linux 定时备份数据库及文件
2014-12-24 18:41 4531、创建保存备份文件的路径/mysqldata ... -
Mysql 修复表
2014-12-17 11:13 528数据库:mysql -uroot -p 1 ... -
msql 乱码
2014-09-01 16:11 560mysql> SHOW VARIABLES LIKE ... -
c3p0
2014-07-10 11:26 576#驱动 c3p0.driverClass=net.sour ... -
SQLServer 2005 识别连接到服务器的客户端
2014-06-24 18:32 595以下示例返回连接到服务器的连接数,并显示起始 IP 地址和 ... -
mysql 允许远程登陆
2014-02-26 11:08 600当安装完数据库后,会发现由于权限控制,导致不能远程连接 ... -
Mysql备份
2014-01-17 11:38 650mysqldump --add-drop-table -u ... -
命令启动Mysql
2014-01-06 15:08 559@echo off copy C:\Program Fi ... -
mysql 授权用户远程登陆
2013-12-19 12:09 629你想myuser使用mypassword从任何主机连接到mys ... -
ORACLE备份与恢复
2012-12-29 14:06 712第一步: 导出数据库: 1 将数据库TEST完全导出,用户 ... -
Oracle
2012-11-21 22:57 0修改 sqlplus /nolog; connec ... -
通用数据库分页 扩展dbutil (附代码下载)
2012-01-08 14:53 4208需求:最近接触一个项 ... -
Sql中使用变量
2011-09-27 11:36 6551.同时更新2个字段:update 帐号表2 s ... -
SQL中显示表名和字段名
2010-10-15 12:18 1679sql语句读取sqlserver和access中的所有表名 ... -
查询MS SQL Server中表占用空间
2010-04-08 16:31 1177select object_name(id) tablenam ...
相关推荐
Dbutil,全称为Apache Commons DbUtils,是一款由Apache软件基金会开发的开源Java工具包,它为JDBC(Java Database Connectivity)提供了一层简单的封装,旨在让数据库操作变得更加便捷且不易出错。DbUtil的设计目标...
DBUtil工具类是Java开发中常见的一种数据库操作辅助类,它的主要目的是为了简化数据库的CRUD(创建、读取、更新、删除)操作,提高开发效率。DBUtil通常集成了连接池技术,如Druid、C3P0或HikariCP等,以优化数据库...
DBUtil 是一个在ASP.NET开发环境中常用的数据库连接工具类,它的设计目的是为了简化数据库操作,减少程序员编写重复的连接和断开数据库的代码,从而提高开发效率和代码的可维护性。通过使用DBUtil,开发者可以快速地...
DBUtil工具类是Java开发中常见的一种设计,用于简化数据库操作,提高开发效率。它通常包含了一系列静态方法,可以执行SQL语句,处理结果集,进行数据库连接的创建、管理和关闭等。这样的工具类在DAO(数据访问对象)...
韩顺平SqlHelper和DBUtil工具类是为了解决这一问题而设计的,它们提供了一种方便的方式来处理SQL Server数据库。这两个工具类是非静态的,这意味着它们可以被实例化并复用,从而避免了静态类可能带来的线程安全问题...
DButil 是一个数据库操作工具类,它封装了常见的SQL操作,如模糊查询、分页查询、数据的增删改查等。这样的工具类在实际开发中非常常见,它简化了数据库交互的代码,提高了开发效率。下面将详细介绍DButil封装中的...
在Laravel框架中,`dbutil`通常指的是数据库操作的实用工具或自定义库,它扩展了Laravel原生的数据库处理能力,提供了一系列便利的方法,以帮助开发者更高效地进行数据操作。本文将深入探讨Laravel开发中的`dbutil`...
在这个场景下,`DBUtil` 类被用来简化与C3P0连接池的交互,以方便地进行数据库操作。下面我们将详细探讨`DBUtil` 的使用方法以及C3P0连接池的工作原理。 1. **C3P0简介** C3P0是由Miguel Grinberg创建的一个开源...
`DbUtil`是一个常见的数据库操作工具类,用于简化数据库连接的创建、关闭等操作,而Tomcat数据源(JNDI数据源)是应用服务器(如Tomcat)提供的一种管理数据库连接的机制。这两种方式都能有效地管理和优化数据库连接...
在Java编程中,数据库操作是不可或缺的一部分,而`dbutil`通常是指用于简化数据库操作的工具包或类库。在本场景中,我们讨论的是如何使用Java与SQL Server进行连接,以及可能涉及到的XML配置文件的修改。下面将详细...
"dbutil+c3p0"这个组合涉及到两个关键组件:DBUtils和C3P0,它们都是Java数据库连接(JDBC)的辅助工具,使得数据库操作更加高效和便捷。下面将详细阐述这两个工具以及它们在实际应用中的作用。 首先,DBUtils是...
本主题将深入探讨“通用数据库分页”以及如何通过扩展dbutil工具来实现这一功能。我们将从以下几个方面展开讨论: 1. **数据库分页原理**: 数据库分页的基本思想是将数据分成若干个页,每次只返回用户请求的一页...
DBUtil类内部包含有连接池创建和连接池的关闭,下载后记得修改URL
在IT行业中,数据库操作是核心任务之一,而DBUtil包作为一种通用的数据库操作工具,能够极大地简化编程工作。本文将详细解析DBUtil包的使用、SQL Server 2005驱动包的功能,以及ASCII编码字符集的相关知识。 首先,...
DBUtil和c3p0则是两个在Java开发中常用的数据库连接池工具,它们可以提高数据库操作的效率和性能。 **MySQL** MySQL是一个开源、免费的SQL数据库,提供了强大的数据存储和查询能力。它的优点包括高效、稳定、易于...
Struts2、DisplayTag和DbUtil是Java Web开发中常用的三个框架或库,它们在构建高效、可维护的Web应用程序中发挥着重要作用。 Struts2是Apache软件基金会下的一个开源MVC(Model-View-Controller)框架,它提供了一...
`.NET连接Mysql - MYSQL4dotNet-DBUtil`这个项目是专为使用C#语言在Windows CE(Wince)环境下连接MySQL数据库而设计的一个实用工具类库。`DBUtil.cs`文件很可能是这个库的核心组件,它提供了方便的方法来执行SQL...
本教程将围绕"DBUtil",一个简单的JDBC工具类,来介绍如何使用配置文件进行SQL连接和数据库的基本操作。这个工具类适用于初学者学习数据库连接管理。 首先,我们来看"db.properties"文件,这是用来存储数据库连接...
DBUtil的类,在WEB开发当中有许多项目都需要用它,可以不用重复写,这样很方便
Oracle JDBC DbUtil 是一个用于简化Java应用程序与Oracle数据库交互的工具包。这个工具包通过提供便利的类和方法,使得开发者能够更高效地执行SQL语句、管理数据库连接以及处理结果集。在给定的文件中,我们可以看到...