?? persondaoimpl.java
字號:
package cn.mldn.lxh.note.dao.impl ;
import java.sql.* ;
import cn.mldn.lxh.note.vo.* ;
import cn.mldn.lxh.note.dbc.* ;
import cn.mldn.lxh.note.dao.* ;
public class PersonDAOImpl implements PersonDAO
{
/*
功能:
· 判斷是否是正確的用戶名或密碼
· 從數據庫中取出用戶的真實姓名
*/
public boolean login(Person person) throws Exception
{
boolean flag = false ;
String sql = "SELECT name FROM person WHERE id=? and password=?" ;
PreparedStatement pstmt = null ;
DataBaseConnection dbc = null ;
dbc = new DataBaseConnection() ;
try
{
pstmt = dbc.getConnection().prepareStatement(sql) ;
pstmt.setString(1,person.getId()) ;
pstmt.setString(2,person.getPassword()) ;
ResultSet rs = pstmt.executeQuery() ;
if(rs.next())
{
flag = true ;
person.setName(rs.getString(1)) ;
}
rs.close() ;
pstmt.close() ;
}
catch (Exception e)
{
throw new Exception("操作出現錯誤!!!") ;
}
finally
{
dbc.close() ;
}
return flag ;
}
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -