81,091
社区成员
发帖
与我相关
我的任务
分享
<select id="getBlackList" parameterClass="String" resultClass="BlackList">
select * from black_list where phone_number=#phoneNumber# //字符串参数也应该是这样传的,可就是查不出
</select>
@Test
public void t()
{
BlackList bl = new BlackList();
bl = DaoFactory.getBlackListDaoInstance().findByNumber("150");
System.out.println(bl.getListId()); //取得查出的该条记录的id,可就查不出,查出的结果是0,数据库中有该记录的
}
2009-09-29 09:37:37,875 DEBUG
[com.ibatis.common.jdbc.SimpleDataSource] - Created connection
30936685.
2009-09-29 09:37:37,906 DEBUG [java.sql.Connection] - {conn-100000}
Connection
2009-09-29 09:37:37,906 DEBUG [java.sql.Connection] - {conn-100000}
Preparing Statement: select * from black_list where phone_number=?
2009-09-29 09:37:38,000 DEBUG [java.sql.PreparedStatement] - {pstm-
100001} Executing Statement: select * from black_list where phone_number=?
2009-09-29 09:37:38,000 DEBUG [java.sql.PreparedStatement] - {pstm-100001} Parameters: [150]
2009-09-29 09:37:38,000 DEBUG [java.sql.PreparedStatement] - {pstm-100001} Types: [java.lang.String]
2009-09-29 09:37:38,000 DEBUG [java.sql.ResultSet] - {rset-100002}
ResultSet2009-09-29 09:37:38,046 DEBUG
[com.ibatis.common.jdbc.SimpleDataSource] - Returned connection 30936685 to pool.
<resultMap id="BlackListResult" class="BlackList">
<result property="listId" column="list_id"/>
<result property="phoneNumber" column="phone_number"/>
<result property="numberType" column="number_type"/>
</resultMap>
private static final long serialVersionUID = 6218562431438580204L;
private long listId; //名单id
private String phoneNumber ; //手机号
private String numberType ; //手机号所属的类别
public long getListId() {
return listId;
}
public void setListId(long listId) {
this.listId = listId;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getNumberType() {
return numberType;
}
public void setNumberType(String numberType) {
this.numberType = numberType;
}
public BlackList findByNumber(String phoneNumber) {
BlackList bl = null;
try {
bl = (BlackList)sqlMap.queryForObject("getBlackList", phoneNumber);
}catch(SQLException e){
e.printStackTrace();
}
return bl;
}