此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【XINGDONGLI】截止到2008-07-29 16:27:18的历史汇总数据(不包括此帖):
发帖的总数量:5 发帖的总分数:40 每贴平均分数:8
回帖的总数量:4 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:5 未结的总分数:40
结贴的百分比:0.00 % 结分的百分比:0.00 %
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
楼主【XINGDONGLI】截止到2008-07-29 16:27:18的历史汇总数据(不包括此帖):
发帖的总数量:5 发帖的总分数:40 每贴平均分数:8
回帖的总数量:4 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:5 未结的总分数:40
结贴的百分比:0.00 % 结分的百分比:0.00 %
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
解决方案 »
- java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
- HttpClinet包的问题
- Sevlet如何获取到jsp页面中的一个超级链接标签中的内容?
- 高手求救,关于Servlet
- mysql 的数据库表生成hibernate的问题。。。。。。急
- session中有个list ,list中放的item中有个价格属性, 现在要输出这个总价,怎么用jstl 把它搞出来
- 采用Java语言实现实时视频的开启和停止
- 关于hibernateFilter的一个问题,困扰了我一个星期了,请帮帮我。
- 请问在TOMCAT5.0中怎么发布2个网站?
- import javax.ws.rs.Produces
- iframe惹得祸
- Struts2中的类是否是单例的?
查询结束如果关闭结果集
就啥都没有了
所以一般都要存放到List中
import java.sql.*;
import java.io.*;/**************************************************
* author:East(张栋芳)
* date:2008-6-13
* note:打开数据库的连接,和关闭连接
**************************************************/public final class DataBaseOperator {
public DataBaseOperator() {
}
/***
*连接数据库用户指定driver,url,user,pwd
*/
public static Connection createConnection(String driver,String url,String user,String pwd){
Connection con = null;
try{
Class.forName(driver);
con = DriverManager.getConnection(url,user,pwd);
}catch(ClassNotFoundException ce){
ce.printStackTrace();
}catch(SQLException se){
se.printStackTrace();
}
return con;
}
/***
*连接数据库用户用默认的SQL server 2000的纯驱动
*/
public static Connection createConnection(){
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=pubs";
String user = "sa";
String pwd = "";
return createConnection(driver,url,user,pwd);
}
/***
*创建一个连接通过配制文件
*/
public static Connection createConnection(String fileName){
String driver="";
String url="";
String user="";
String pwd="";
BufferedReader in = null;
try{
in = new BufferedReader(new FileReader(fileName));
driver = in.readLine();
url = in.readLine();
user = in.readLine();
pwd = in.readLine();
in.close();
}catch(IOException ioe){
ioe.printStackTrace();
}
return createConnection(driver,url,user,pwd);
}
/***
*创建一个连接桥驱动
*/
public static Connection createConnection(String driver,String url){
driver = "sun.jdbc.odbc.JdbcOdbcDriver";
url = "jdbc:odbc:myodbc";
String user = "sa";
String pwd = "";
return createConnection(driver,url,user,pwd);
}
/***
*关闭连接。con,pstmt,rs;
*/
public static void closeAll(Connection con,PreparedStatement pstmt,ResultSet rs){
try{
if(rs != null)rs.close();
if(pstmt != null) pstmt.close();
if(con != null) con.close();
}catch(SQLException se){
se.printStackTrace();
}finally{
rs = null;
pstmt = null;
con = null; }
}
/***
*关闭连接。con,pstmt;
*/
public static void closeAll(Connection con,PreparedStatement pstmt){
try{
if(pstmt != null) pstmt.close();
if(con != null) con.close();
}catch(SQLException se){
se.printStackTrace();
}finally{
pstmt = null;
con = null;
}
}
/***
*关闭连接。con
*/
public static void closeAll(Connection con){
try{
if(con != null) con.close();
}catch(SQLException se){
se.printStackTrace();
}finally{
con = null;
}
}
/**
*关闭一个连接con,stmt,rs
*/
public static void closeAll(Connection con,Statement stmt,ResultSet rs){
try{
if(con != null) con.close();
if(stmt != null) stmt.close();
if(rs != null) rs.close();
}catch(SQLException se){
se.printStackTrace();
}
}
/**
*关闭一个连接con,stmt
*/
public static void closeAll(Connection con,Statement stmt){
try{
if(con != null) con.close();
if(stmt != null) stmt.close();
}catch(SQLException se){
se.printStackTrace();
}
}}