package com.myit.util;import java.lang.reflect.Field;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.ResultSetMetaData;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;public class DBHelper { private static final String DRIVER="com.mysql.jdbc"; private static final String URL="jdbc:mysql://localhost:3306/dvd"; private static final String USER="root"; private static final String PASSWORD="root"; /** * 连接数据库 * @return 链接数据库对象 */ public Connection getConnection(){ Connection conn=null; try { Class.forName(DRIVER); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { conn=DriverManager.getConnection(URL, USER, PASSWORD); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return conn; } /** * 释放相应的资源 * @param rs * @param pstmt * @param conn */ public void closeAll(ResultSet rs,PreparedStatement pstmt,Connection conn){ try { if(rs!=null){ rs.close(); } if(pstmt!=null){ pstmt.close(); } if(conn!=null){ conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * 此方法可以完成增删改所有的操作 * @param sql * @param params * @return true or false */ public boolean excuteUpdate(String sql,List