public class ConnetMySQL { public static final String URL = "jdbc:mysql://127.0.0.1:3306/Jinke_Cloud_print"; public static final String DRIVER = "com.mysql.jdbc.Driver"; public static final String USER1 = "root"; public static final String PSW = ""; public Connection coon = null; public Statement stmt = null; public ConnetMySQL() { try { Class.forName(DRIVER); coon = DriverManager.getConnection(URL,USER1,PSW); stmt = coon.createStatement(); } catch(Exception e) { e.printStackTrace(); } } public void close() { try { this.coon.close(); this.stmt.close(); } catch(SQLException e) { e.printStackTrace(); } } public boolean isExist(String UserName,String UserPSW) { try { ResultSet rs = null; rs = stmt.executeQuery("select *from cuser"); while(rs.next()) { if(UserName.equals(rs.getString("userName"))&&UserPSW.equals(rs.getString("userPSW"))) return true; } } catch(SQLException e) { e.printStackTrace(); } return false; } }
Java追随者
相关分类