orcal数据库 搞不定了
package com.fendou.db;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.fendou.dao.mapper.IResultMapper;
import com.fendou.po.Member;
public class findPass extends DaoOperate {
private Connection conn = null;
private PreparedStatement pstmt = null;
private ResultSet rs = null;
public Member findPa(String sql, Object[] params, IResultMapper mapper)
throws Exception {
Member m = null;
try {
conn = DBUtil.getInstance().getConn();
pstmt = conn.prepareStatement(sql);
if (params != null) {
int len = params.length;
for (int i = 0; i < len; i++) {
pstmt.setObject(i + 1, params[i]);
}
}
rs = pstmt.executeQuery();
while (rs.next()) {
m = (Member) mapper.getObject(rs);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtil.closed(rs, pstmt, conn);
}
return m;
}
public Member selM(String sql, Object[] params, IResultMapper mapper)
throws Exception {
Member m = null;
try {
conn = DBUtil.getInstance().getConn();
pstmt = conn.prepareStatement(sql);
if (params != null) {
int len = params.length;
for (int i = 0; i < len; i++) {
pstmt.setObject(i + 1, params[i]);
}
}
rs = pstmt.executeQuery();
while (rs.next()) {
m = (Member) mapper.getObject(rs);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtil.closed(rs, pstmt, conn);
}
return m;
}
}
能给我详细讲讲每条语句吗? --------------------编程问答-------------------- 就是2个执行sql的方法呀, 从DBUtil获取connection对象,执行sql
补充:Java , Web 开发