package com.DBUtils;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.HashMap;import java.util.List;import java.util.Map;import com.bean.UserInfo;public class JdbcUtils { private static final String USERNAME = "system";//数据库用户名 private static final String PASSWORD = "zZ123456";//数据库密码 private static final String DRIVER = "oracle.jdbc.driver.OracleDriver";//驱动信息 private static final String URL = "jdbc:oracle:thin:@localhost:1521:bookstore";//数据库地址 private Connection connection = null; private PreparedStatement statement = null; private ResultSet resultSet = null; public JdbcUtils() { try { Class.forName(DRIVER); System.out.println("Connect database Successlly!"); } catch (ClassNotFoundException e) { e.printStackTrace(); } } /** * 得到数据库连接 * @return connection */ public Connection getConnection() { try { connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); } catch (SQLException e) { e.printStackTrace(); } return connection; } /** * 更新操作(增删改) * @param sql * @param params * @return boolean * @throws SQLException */ public boolean updateByPreparedStatement(String sql,List
package com.bean;import java.io.Serializable;import java.util.Arrays;import java.util.Date;public class UserInfo implements Serializable{ private static final long serialVersionUID = 1L; private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "UserInfo [username=" + username + ", password=" + password + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]"; } }