标题:sqlserver2000 关闭连接出现的问题
只看楼主
fly521
Rank: 2
来 自:河南
等 级:论坛游民
帖 子:11
专家分:20
注 册:2009-6-7
结帖率:100%
 问题点数:0 回复次数:0 
sqlserver2000 关闭连接出现的问题
package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


import db.DBconn;

import entity.User_info;

public class LoginDao {
    Connection conn;
   
    public User_info checkLogin(String name,String password){
        conn=DBconn.getconn();
        try {
            PreparedStatement pstmt=conn.prepareStatement("select * from login where name=? and password=?");
            pstmt.setString(1, name);
            pstmt.setString(2, password);
            ResultSet rs=pstmt.executeQuery();
            if(rs.next()){
                User_info user=new User_info();
                user.setName(rs.getString(1));
                user.setPassword(rs.getString(2));
               
                return user;
            }
            
            else    return null;
            
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;
        }finally {
                       //这里加上关闭数据库的方法不能运行 也不报错  去掉后能运行
                      }
        
    }

}
搜索更多相关主题的帖子: password package public import where 
2010-11-03 21:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-324903-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.120827 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved