commons-dbutils使用介绍,commons-dbutils是JDBC的替代品
commons-dbutils 是Apache开源组织提供的用于操作数据库的工具包。今天为大家介绍一下该包的常用方法。 对于数据库的操作无外乎增删改查,而增删改本质上可以归为一类,操作方式相同,只是SQL语法不同而已,所以我将以修改和查询两类来介绍 commons-dbutils 的用法。 首先我们来创建一个测试类,使用JUnit进行测试。 import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import org.apache.commons.dbutils.DbUtils; import org.apache.commons.dbutils.QueryRunner; import org.junit.After; import org.junit.Before; import org.junit.Test; public class DBUtilsTest { private Connection conn = null; @Before public void initConnection() throws SQLException, ClassNotFoundException { printCurrentMethodName(); Class