packagecom.DateSystem;importjava.sql.Connection;importjava.sql.Date;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjava.util.LinkedList;importjava.util.List;importjavax.swing.text.StyledEditorKit.BoldAction;publicclassUserdate{//登陆publicListUserfindUser(Stringsql){ListUserusers=newLinkedListUser();Statementstatement=null;ResultSetresultSet=null;Connectionconnection=ConnectionDriver.getConnection();try{statement=connection.createStatement();resultSet=statement.executeQuery(sql);while(resultSet.next()){StringnameString=resultSet.getString(1);StringpasswString=resultSet.getString(2);Useruser=newUser();user.setUsername(nameString);user.setPassword(passwString);users.add(user);}}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}finally{JDBcloss.close(resultSet,statement,connection);}returnusers;}//修改密码publicbooleanupdataUser(Stringsql){booleanflag=false;Statementstatement=null;Connectionconnection=ConnectionDriver.getConnection();try{statement=connection.createStatement();inti=statement.executeUpdate(sql);if(i0){flag=true;}}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}finally{JDBcloss.close(statement,connection);}returnflag;}//添加用户publicbooleanadd_user(Stringsql){booleanflag=false;Statementstatement=null;Connectionconnection=ConnectionDriver.getConnection();try{statement=connection.createStatement();inti=statement.executeUpdate(sql);if(i0){flag=true;}}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}finally{JDBcloss.close(statement,connection);}returnflag;}//录入商品数据操作//删除操作publicbooleanadd_goods(Stringsql){booleanflag=false;Statementstatement=null;Connectionconnection=ConnectionDriver.getConnection();try{statement=connection.createStatement();inti=statement.executeUpdate(sql);if(i0){flag=true;}}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}finally{JDBcloss.close(statement,connection);}returnflag;}//主界面加载数据库publicResultSetonlowd(Stringsql){Statementstatement=null;ResultSetresultSet=null;Connectionconnection=ConnectionDriver.getConnection();try{statement=connection.createStatement();resultSet=statement.executeQuery(sql);}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}finally{JDBcloss.close(resultSet,statement,connection);}returnresultSet;//将得到的数据集合返回}//}