社区
Web 开发
帖子详情
高分求助!关于数据库连接问题
jason_gy
2003-11-04 09:20:31
我用的是连接池,老是出现“连接占线导致另一个 hstmt ”,这是什么问题?
怎么解决?
...全文
107
7
打赏
收藏
高分求助!关于数据库连接问题
我用的是连接池,老是出现“连接占线导致另一个 hstmt ”,这是什么问题? 怎么解决?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
lovelanzhi716
2003-11-17
打赏
举报
回复
是你的驱动程序不行,你是用的jdbc-odbc吧
它好像不行,你下载一个sql2000 for jdbc就可以了
xqg1130
2003-11-17
打赏
举报
回复
关注
jason_gy
2003-11-17
打赏
举报
回复
我是这样用的请各位看看有什么问题???
/*******************
该程序实现“系统登陆的默认页面‘中的存储过程,待办事务、个人消息、公告栏
*******************/
package oadb;
import java.sql.*;
import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Main{
private CallableStatement stmtProc=null;//定义存储过程的语句对象
private CallableStatement stmtPub=null;//定义存储过程的语句对象
Statement stmt = null;
private Connection Con = null;
private ConnManager Cmgr;
public Main(){
try{
Cmgr=ConnManager.getInstance();
if(Cmgr == null){
return;
}
Con = Cmgr.getConnection();///申请连接
Cmgr.freeConnection(Con);//释放连接
}catch(Exception e){
System.err.println("系统登陆的默认页面取得连接错误:" + e.getMessage());
}
}
//-----------------------------显示待办事务列表---------------------------------------------------
public ResultSet UndoAffair(String S_CurUserID){
ResultSet R_UA = null ; //记录集
String Sql = "SELECT Rtrim(AffairType) AS AffairType, AffairFileID, AffairTitle, UrgentLevel, CurNodeName, SendUserName, FileState, CONVERT(varchar(16), ArriveTime, 20) AS ArriveTime FROM UndoAffair where UserID='"+S_CurUserID+"'";
try{
stmt = Con.createStatement();
R_UA = stmt.executeQuery(Sql);
}
catch(Exception sqld){
System.err.println("显示待办事务列表储过程错误:"+sqld.getMessage());
}
stmt=null;
return R_UA;
}
//-----------------------------------------显示个人消息列表---------------------------------------
public ResultSet MsgPerson(String S_CurUserID){
ResultSet R_MPer = null;
String Sql ="select MessageID,Title,UserName,DeptName,CONVERT(varchar(16), SendDate, 20) AS SendDate from V_MsgPerson where (getdate()<AvailedTime)and (BorwserID='"+S_CurUserID+"')";
try{
stmt = Con.createStatement();
R_MPer = stmt.executeQuery(Sql);
}
catch(Exception sqld){
System.err.println("显示个人消息列表,储过程错误"+sqld.getMessage());
}
stmt=null;
return R_MPer;
}
//-------------------------------------------显示公告栏列表----------------------------------------
public ResultSet MsgPub(){
String Sql = null;
ResultSet R_MPub = null;
try {
Sql="{CALL Pr_MsgPub}";
stmtPub=Con.prepareCall(Sql);
R_MPub = stmtPub.executeQuery();
stmtPub=null;
}catch(SQLException ex){
System.err.println("显示公告栏列表,储过程错误:" + ex.getMessage());
}
return R_MPub;
}
//------------------------------计算两个日期的间隔天数----------------------------------------------
public long Date_Compare(String S_DateStart,String S_DateEnd){
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
long day=0;
try{
java.util.Date date= myFormatter.parse(S_DateStart);
java.util.Date mydate= myFormatter.parse(S_DateEnd);
day=(date.getTime()-mydate.getTime())/(24*60*60*1000);
//System.out.println(day);
}catch(Exception e){System.err.println("计算两个日期的间隔天数错误:" + e.getMessage());}
return day;
}
//---------------------------------------取得服务器时间--------------------------------------------
public String Sys_Date(){
String strSql = null;
String str_date = "";
String D_SysDate = "";
try {
strSql="{call Pr_CurSysDateTime(?)}";
stmtProc=Con.prepareCall(strSql);
stmtProc.setString(1,str_date);
stmtProc.registerOutParameter(1,java.sql.Types.VARCHAR);
stmtProc.execute();
D_SysDate = stmtProc.getString(1);
stmtProc.close();
stmtProc=null;
}catch(SQLException ex){
System.err.println("取得服务器时间,储过程错误:" + ex.getMessage());
}
return D_SysDate;
}
//------------------------------------从消息提示表中查询当前人的数据-----------------------------------.
public String MsgReSet(String S_CurUserID){
String Sql = "Select Rtrim(MsgMatter) as MsgMatter,Rtrim(UserName) as UserName,CONVERT(varchar(16), ArriveTime, 20) AS ArriveTime From V_MsgHint where UserID='"+S_CurUserID+"'";
ResultSet Rs = null;
String S_MsgTable="<table border='1' width='100%' cellspacing='1'>";
String S_MsgMatter="";
String S_UserName="";
String S_ArriveTime="";
try {
stmt = Con.createStatement();
Rs=stmt.executeQuery(Sql);
while (Rs.next())
{
S_MsgMatter=Rs.getString("MsgMatter");
S_UserName=Rs.getString("UserName");
S_ArriveTime=Rs.getString("ArriveTime");
S_MsgTable+="<tr><td>"+S_UserName+":给您传来一条"+S_MsgMatter+",时间:"+S_ArriveTime+"请返回页首查看.</td></tr>";
}
Rs.close();
stmt=null;
S_MsgTable+="</table>";
}catch(SQLException ex){
System.err.println("从消息提示表中查询当前人的数据,储过程错误:" + ex.getMessage());
}
return S_MsgTable;
}
//-----------------------从消息提示表中查询当前人是否有新的数据-----------------------------------
public int MsgNew(String S_CurUserID){
String Sql = "Select MsgMatter From V_MsgHint where UserID='"+S_CurUserID+"'";
ResultSet Rs = null;
int I_Count=0;
try {
stmt = Con.createStatement();
Rs=stmt.executeQuery(Sql);
while (Rs.next())
{
//I_Count=Rs.getInt("MsgMatter");
I_Count++;
}
Rs.close();
stmt=null;
}catch(SQLException ex){
System.err.println("从消息提示表中查询当前人是否有新的数据,储过程错误:" + ex.getMessage());
}
return I_Count;
}
//-------------------删除消息提示表中有关该用户的信息-------------------------------------------
public void Msg_Del(String S_CurUserID){
String strSql = null;
try {
strSql="{call Pr_DelMsgHint(?)}";
stmtProc=Con.prepareCall(strSql);
stmtProc.setString(1,S_CurUserID);
stmtProc.execute();
stmtProc.close();
stmtProc=null;
}catch(SQLException ex){
System.err.println("删除消息提示表中有关该用户的信息,储过程错误:" + ex.getMessage());
}
}
}
kaibinsj
2003-11-12
打赏
举报
回复
一个连接只能建立一个statement??
楼上此言何解???
我就建了两个照样用啊!
marymcl
2003-11-12
打赏
举报
回复
注意使用得statment是否恰当的关闭了
giftxi
2003-11-12
打赏
举报
回复
看看你配置的最大连接数,一个连接只能建立一个STATEMENT,你看看你程序里的STATEMENT是不是有问题,如果数据处理用事物进行处理,需要特别注意这一点。
op2618
2003-11-12
打赏
举报
回复
也许是没配好!
征途linux编译错误,
高分
求助
!征途LINUX架设出现的
问题
!会的来!
100807-16:27:55 SuperServer ERROR: 连接数据库失败 100807-16:27:55 SuperServer TRACE: SuperServer停机 发送拒绝信息到RolechangeServer失败! 100807-16:27:55 SuperServer DEBUG: virtual void zNetService::...
征途私服mysql启动不了_
高分
求助
!征途LINUX架设出现的
问题
!会的来!
100807-16:27:55 SuperServer ERROR: 连接数据库失败 100807-16:27:55 SuperServer TRACE: SuperServer停机 发送拒绝信息到RolechangeServer失败! 100807-16:27:55 SuperServer DEBUG: virtual void zNetService::...
sqlserver数据库分页
问题
sqlserver数据库分页
问题
,急、、、楼主zhaosy(盛)2005-11-03 11:04:18 在 Java / J2SE / 基础类 提问各位兄弟姐妹,这个程序再oracle、mysql上执行没任何
问题
其中:$where为条件,currentPage为当前页码,...
数据库帖子收集
在vb中用什么语句检测与sqlserver
数据库连接
成功 请教制作安装程序包的
问题
。——50分—— 存储过程中如何修改XML 如何让数据库中的数据按照某一字段重新排序 为什么我的事件探查器的objectname的值总为...
Windows Mobile
哪里有专门开发 windows mobile 5.0的网站吗? (mextb1860 @ 2006-9-3 20:32:30) 救命啊,如何调用Media ...
求助
:XmlTextReader读取xml节点下信息的方法,
高分
!!! (Walkline @ 2006-9-2 13:44:38) 在vs2005中...
Web 开发
81,092
社区成员
341,716
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章