获取后台数据的方法
Connection conn = DBUtils.getInstance().getConn();
PreparedStatement pstmt = null;
ResultSet rset = null;
TestSheet testSheet=null;
String sql = "select * from test_sheet where sheet_no=?";
try{ pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sheetNo);
rset = pstmt.executeQuery();
testSheet = new TestSheet(); if(rset!=null && rset.next()){
该处为数据值获取
}
}catch(SQLException e){
e.printStackTrace();
}finally{
DBUtils.getInstance().ReleaseRes(conn, null, null);
}
return testSheet; /**
* 获取数据库连接
* @return
*/
//synchronized 保证在多线程并发环境下,该方法在单一事件内只有一个线程在访问。
public synchronized Connection getConn()
{
Connection conn=null;
//先从当前线程上取出连接实例
conn = tl.get();
if(conn==null) {//如果当前线程上没有绑定连接,则向连接池申请一个新的连接
try {
//先从当前线程上取出连接实例
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
conn=DriverManager.getConnection("proxool.testsys-ds");
tl.set(conn);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return conn;
}
/**
* 释放数据库资源
* @param conn
* @param pstmt
* @param rset
*/
public void ReleaseRes(Connection conn,PreparedStatement pstmt,ResultSet rset)
{
try{
if(rset!=null) rset.close();
if(pstmt!=null) pstmt.close();
if(conn!=null) {
tl.remove();//卸装线程绑定
conn.close();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}断点设置后,sql语句在PL/SQL中可以查到一条数据。但是接着运行断点,在rset.next()时并没有获取数据,也就是rset为空集,这是什么问题
Connection conn = DBUtils.getInstance().getConn();
PreparedStatement pstmt = null;
ResultSet rset = null;
TestSheet testSheet=null;
String sql = "select * from test_sheet where sheet_no=?";
try{ pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sheetNo);
rset = pstmt.executeQuery();
testSheet = new TestSheet(); if(rset!=null && rset.next()){
该处为数据值获取
}
}catch(SQLException e){
e.printStackTrace();
}finally{
DBUtils.getInstance().ReleaseRes(conn, null, null);
}
return testSheet; /**
* 获取数据库连接
* @return
*/
//synchronized 保证在多线程并发环境下,该方法在单一事件内只有一个线程在访问。
public synchronized Connection getConn()
{
Connection conn=null;
//先从当前线程上取出连接实例
conn = tl.get();
if(conn==null) {//如果当前线程上没有绑定连接,则向连接池申请一个新的连接
try {
//先从当前线程上取出连接实例
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
conn=DriverManager.getConnection("proxool.testsys-ds");
tl.set(conn);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return conn;
}
/**
* 释放数据库资源
* @param conn
* @param pstmt
* @param rset
*/
public void ReleaseRes(Connection conn,PreparedStatement pstmt,ResultSet rset)
{
try{
if(rset!=null) rset.close();
if(pstmt!=null) pstmt.close();
if(conn!=null) {
tl.remove();//卸装线程绑定
conn.close();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}断点设置后,sql语句在PL/SQL中可以查到一条数据。但是接着运行断点,在rset.next()时并没有获取数据,也就是rset为空集,这是什么问题
解决方案 »
- jsp超链接
- 一起使用:MyEclipse6.0.1和JAVAEE5和JSTL的兄弟进来看一下
- vista下能跑oracle和tomcat\eclipse\jdk等吗?
- JSP中怎样让input适应table中每一个格子的大小?在线等,急
- 老老们我的程序又出现新问题。。。请进
- jsp中如何调用标准的ocx控件~
- 本人遇到一个很诡异的问题
- 开发过程中本地静态资源怎么处理
- urlrewrite 伪静态:匹配汉字 字符 字母下划线 数字的正则表达式??
- 如何在B/S模式下,用java实现增删改查
- java文件上传,页面File值没有传到Action中
- java_ee_sdk-6u3_jdk7-windows-64 安装问题
if(rset!=null && rset.next()){
是不是这里的原因啊
该处为数据值获取
}这里,不知道你if内是怎么取值的,但是绝对别再出现next()