import java.sql.*;
import java.util.Scanner;

public class UserLogin11_4 
{
	public static void main(String[] args) 
	{
		String user = "root";
		String password = "123456";
		String url = "jdbc:mysql://localhost:3306/test";
		try 
		{
			Class.forName("com.mysql.jdbc.Driver");	//Java 6 д˾ʡԲд
			Connection conn = DriverManager.getConnection(url, user, password);
			try 
			{
				Scanner sc = new Scanner(System.in);
				System.out.println("û룺");
				System.out.print("û");
				user = sc.nextLine();
				System.out.print("룺");
				password = sc.nextLine();
				String sql = "select id from users where name =";
				sql = sql + "'" + user + "' and password =";
				sql = sql + "'" + password + "'";
				Statement stat = conn.createStatement();
				ResultSet rs = stat.executeQuery(sql);
				if(rs.next()==true) 
				{	//ѯ
					System.out.println("ûڣ¼ɹ");
				}else 
				{	//ѯΪ
					System.out.println("ûڻ󣬵¼ʧܣ");
				}
			} finally 
			{
				conn.close();
			}
		} catch (Exception e) 
		{
			e.printStackTrace();
		}
	}
}