package com.mrt.powerMg.service;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import com.mrt.common.dao.MySQL;
import com.mrt.powerMg.bean.Admin;
/**
* 商品表Dao
*
* @author Administrator
*
*/
public class AdminDao {
public static void main(String[] args) {
// AdminDao dao = new AdminDao();
// Admin admin = new Admin();
//
// admin.setName("李四");
// admin.setLogin_name("老李");
// admin.setDes("不错");
//
// dao.add(admin);
//dao.deleteById("1,2");
// Admin Admin = dao.getAdminById(4);
// Admin.setName("联想电脑(新)");
// dao.modify(Admin);
// System.out.println(admin);
}
public Admin Login(String name,String password){
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = MySQL.getConnection();
preparedStatement = connection.prepareStatement("select id, name, des, login_name from admin where login_name=? and password=?");
preparedStatement.setString(1, name);
preparedStatement.setString(2, password);
resultSet = preparedStatement.executeQuery();
System.out.println(resultSet.next());
while(resultSet.next());
{
Admin admin = new Admin();
System.out.println(resultSet);
admin.setLogin_name(name);
admin.setId(resultSet.getInt(1));
admin.setName(resultSet.getString(2));
admin.setDes(resultSet.getString(3));
return admin;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {resultSet.close();} catch (Exception e2) {}
try {preparedStatement.close();} catch (Exception e2) {}
try {connection.close();} catch (Exception e2) {}
}
return null;
}
|
|