Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package loginapp;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.sql.ResultSet;
- import DbUtil.dbconnection;
- public class LoginModel {
- Connection connection;
- public LoginModel(){
- try{
- this.connection = dbconnection.getConnection();
- }catch(SQLException ex){
- ex.printStackTrace();
- }
- if(this.connection==null){
- System.exit(1);
- }
- }
- public boolean isDataBaseConnected(){
- return this.connection != null;
- }
- public boolean isLogin(String username,String password)throws Exception{
- PreparedStatement pr = null;
- ResultSet rs = null;
- System.out.println("Login " + username + " Pass " + password);
- //String sql= "SELECT * FROM login where username = ? and password = ? ";
- String sql2 ="CREATE TABLE `loginos` ( `username` TEXT, `password` TEXT )";
- try {
- pr = this.connection.prepareStatement(sql2);
- //pr.setString(1, username);
- //pr.setString(2, password);
- pr.executeUpdate();
- boolean boll1;
- if (rs.next()) {
- return true;
- }
- return false;
- }catch(SQLException ex){
- System.out.println(ex);
- return false;
- }
- finally {
- pr.close();
- rs.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement