The interface has been upgraded to add the user registration in the login screen, more perfect function to be continued ....
Main code:
1 PackageDataBase;2 3 Importjava.sql.Connection;4 ImportJava.sql.ResultSet;5 Importjava.sql.SQLException;6 Importjava.sql.Statement;7 8 Public classSingupconnect {9 PrivateConnection Connection;Ten PrivateStatement Statement; One ResultSet ResultSet; A PrivateString name; - PrivateString password; - PublicString GetName () { the returnname; - } - Public voidsetName (String name) { - This. Name =name; + } - PublicString GetPassword () { + returnpassword; A } at Public voidSetPassword (String password) { - This. Password =password; - } - PublicSingupconnect () { -connection=Connectionfactory.getinstane (). MakeConnection (); - } in Public voidsin_in () { -ResultSet resultset=NULL; toString sql= "SELECT * from User"; + Try { -Statement=connection.createstatement (); the}Catch(SQLException e) { * $ e.printstacktrace ();Panax Notoginseng } - Try { theresultset=statement.executequery (SQL); + while(Resultset.next ()) { AName=resultset.getstring ("name"); thePassword=resultset.getstring ("Password"); + } -}Catch(SQLException e) { $ $ e.printstacktrace (); - } - Try { the while(Resultset.next ()) { -System.out.println (resultset.getstring ("username"));WuyiSystem.out.println (resultset.getstring ("Password")); the } -}Catch(SQLException e) { Wu - e.printstacktrace (); About } $ finally{ - Try { - resultset.close (); -}Catch(Exception E2) { A + } the Try { - statement.close (); $}Catch(Exception E2) { the the } the Try { the connection.close (); -}Catch(Exception E2) { in the } the } About the } the Public voidsinup (String name,string password) { the Try { +Connection.setautocommit (false); -Userdao userdao=NewUserdaoimpl (); theUser user=NewUser ();Bayi user.setname (name); the User.setpassword (password); the Userdao.save (connection, user); - connection.commit (); -}Catch(Exception e) { the Try { the Connection.rollback (); the}Catch(Exception E2) { the e2.printstacktrace (); - } the } the } the}
Compounding Calculator 6.0