????//?????????????????????????????
????public static Employee login(String name??String pwd){
????Employee employee = null;
????Connection conn=null;
????//?????????????????
????try {
????Class.forName(“org.sqlite.JDBC”);
????//?????????
????conn = DriverManager.getConnection(“jdbc:sqlite:d:/company.db”);
????//????preparedStatement???????????????SQL???
????PreparedStatement ps = conn.prepareStatement(“select * from employee where name=? and pwd=?”);
????ps.setString(1?? name);
????ps.setString(2?? pwd);
????ResultSet rs = ps.executeQuery();
????while(rs.next()){
????employee = new Employee(rs.getLong(1)??rs.getString(2)??rs.getString(3)??rs.getInt(4));
????}
????} catch (ClassNotFoundException e) {
????e.printStackTrace();
????} catch (SQLException e) {
????e.printStackTrace();
????}finally {
????if(conn!=null){
????try {
????conn.close();
????} catch (SQLException e) {
????// TODO Auto-generated catch block
????e.printStackTrace();
????}
????}
????}
????return employee;
????}
????//?????????е???????????
????public static List fetchData(){
????Employee employee;
????//???????List????
????List list = new ArrayList();
????//???????????
????Connection conn = null;
????try {
????//?????????????????
????Class.forName(“org.sqlite.JDBC”);
????//?????????
????conn = DriverManager.getConnection(“jdbc:sqlite:d:/company.db”);
????//????????SQL???????
????Statement state = conn.createStatement();
????//???SQL?????SQL??????????String??????????
????String string = “Select * from employee”;
????//????Statement?????е??????????SQL????????ResultSet??????????
????ResultSet set = state.executeQuery(string);
????//????next??????get???????????Employee?????У????????б??
????while(set.next()){
????employee = new Employee(set.getLong(1)??set.getString(2)??set.getString(3)??set.getInt(4));
????list.add(employee);
????}
????} catch (ClassNotFoundException e) {
????e.printStackTrace();
????} catch (SQLException e) {
????e.printStackTrace();
????}finally {
????if (conn!= null) {
????try {
????//???????????????????????????conn.
????conn.close();
????} catch (SQLException e) {
????e.printStackTrace();
????}
????}
????}
????return list;
????}
????}