社区
Web 开发
帖子详情
早上好~~好久没来了,散点分,顺便问个问题——WAS3.5+DB2(7.1)连接池问题
dongdongshu
2003-08-11 07:31:23
我用DB27.1+WAS3.5做了一个图书检索网站
对一个8万条数据的表进行检索,我得JAVA BEAN中调用完连接都是及时关闭的,WAS数据源的最大连接数设了20,而且网站访问量也不是很大,可不到几分钟,连接池就会爆满,出现无法连接数据库的故障!
哪位遇到过此类问题,或者帮我推断一下可能性也好啊~
再次感谢!!!
...全文
63
42
打赏
收藏
早上好~~好久没来了,散点分,顺便问个问题——WAS3.5+DB2(7.1)连接池问题
我用DB27.1+WAS3.5做了一个图书检索网站 对一个8万条数据的表进行检索,我得JAVA BEAN中调用完连接都是及时关闭的,WAS数据源的最大连接数设了20,而且网站访问量也不是很大,可不到几分钟,连接池就会爆满,出现无法连接数据库的故障! 哪位遇到过此类问题,或者帮我推断一下可能性也好啊~ 再次感谢!!!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
42 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
双杯献酒
2003-08-12
打赏
举报
回复
UP
xhongyang
2003-08-12
打赏
举报
回复
接分
dongdongshu
2003-08-12
打赏
举报
回复
感谢各位,问题应该基本水落石出了……
lynx1111(人生不如意十有八九!) ——估计的没错~
数据库配置的问题~
唉,谁让我是第一次用DB2呢?
dongdongshu
2003-08-12
打赏
举报
回复
^_^
也没什么神奇的,
你熟悉DB2,对你来说不值一晒,如果不熟悉,说了也没用阿~~
全是没有技术含量的东东……
叫了一个DBA,三下五除二就搞定了,关键是帮朋友做的一个特别急得项目,4天4夜,一个小型的电子商务网站,还在我不熟得架构上……
快累死了,TNND~
(请大家允许我骂骂人,实在太晕)
acefr
2003-08-12
打赏
举报
回复
..........
居然是这个问题??
服了。。。
结帖的时候记得把解决方案贴一下啊~
呵呵
amortal
2003-08-12
打赏
举报
回复
接!学习ing
acefr
2003-08-11
打赏
举报
回复
你一下贴这么多,一看就有点晕,而且你的closeDB()哪里都有,查起来好累的。
尤其是你现在都做完了,测试起来更不容易。
你可以查的到连接池的连接数吧?先把最大连接设成5,然后测试你的页面,记录下哪个操作占用了连接(能不能给个标志?呵呵),然后到释放的时候看看连接数有没有减一,这样查查看。就知道哪里出问题了的,然后才能解决啊~
flyshp
2003-08-11
打赏
举报
回复
你用的是ejb 还是 javabean
程序里 有没有 return.resultset;的方法,然后再jsp 里调用了??
dongdongshu
2003-08-11
打赏
举报
回复
5555
时间紧迫啊~
晕,我总觉得不是程序的问题……
acefr
2003-08-11
打赏
举报
回复
...................
好多。。。
感觉try,catch这么写很容易漏掉的,你可以在:
/**
* 连接数据库。
* @roseuid 3DE57EFA02B9
*/
public static void connDB() {
initDbinst();
dbinst.setConnection();
}
里面就用try,catch,这样子在外面可以直接用connDB(),其它的也是这样,这样检查也比较方便的。
dongdongshu
2003-08-11
打赏
举报
回复
/**
* 连接数据库,根据传进来的sql对数据库纪录进行更新操作,直接提交操作并关闭连接。
* @return int
* @roseuid 3DE57F6A0093
*/
public static int setUpdate(String s_sql) {
int affect_num = 0;
if (s_sql == null || s_sql.equals("")) {
return affect_num;
}
try {
connDB();
affect_num = dbinst.doUpdate(s_sql);
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
return affect_num;
}
}
/**
* 对数据库同时进行多次增加、删除、修改操作
* @return int
* @roseuid 3DE57F6A0093
*/
public static int setUpdate(ArrayList alist_sql) {
int affect_num = 0;
if (alist_sql == null) {
return affect_num;
} else
if (alist_sql.isEmpty()) {
return affect_num;
}
try {
connDB();
affect_num = dbinst.doUpdate(alist_sql);
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
return affect_num;
}
}
/**
* 根据传进来的sql对数据库纪录进行更新操作,不提交操作。
* @return int
* @roseuid 3DE57F6A0093
*/
public static int setUpdateAble(String s_sql) {
int affect_num = 0;
if (s_sql == null || s_sql.equals("")) {
return affect_num;
}
try {
if (dbinst == null) {
System.out.println("Please init dbinst first!");
} else {
affect_num = dbinst.doUpdateAble(s_sql);
}
} catch (Exception e) {
System.out.println("DB error:" + e);
} finally {
return affect_num;
}
}
/**
* 根据传进来的sql对数据库纪录进行更新操作,不提交操作。
* @return int
* @roseuid 3DE57F6A0093
*/
public static int setUpdateAble(ArrayList alist_sql) {
int affect_num = 0;
if (alist_sql == null) {
return affect_num;
} else
if (alist_sql.isEmpty()) {
return affect_num;
}
try {
if (dbinst == null) {
System.out.println("Please init dbinst first!");
} else {
affect_num = dbinst.doUpdateAble(alist_sql);
}
} catch (Exception e) {
System.out.println("DB error:" + e);
} finally {
return affect_num;
}
}
/**
* 根据传进来的sql获取一条数据库纪录中的单个数据值。
* @return String
* @roseuid 3DE57F6A0093
*/
public static String getOneValueAble(String s_sql) {
String s_return = "";
if (s_sql == null || s_sql.equals("")) {
return s_return;
}
ArrayList alist_data = null;
try {
if (dbinst == null) {
System.out.println("Please init dbinst first!");
} else {
alist_data = dbinst.doQueryList(s_sql);
}
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
if (alist_data != null && !alist_data.isEmpty()) {
ArrayList alist_line = (ArrayList) alist_data.get(0);
s_return = (String) alist_line.get(0);
}
return s_return;
}
}
/**
* 根据传进来的sql获取一条数据库纪录中的单个数据值。
* @return String
* @roseuid 3DE57F6A0093
*/
public synchronized static int setUpdateByCheck(
String s_select_sql,
String s_update_sql,
boolean b_next) {
int affect_num = 0;
if (s_select_sql == null
|| s_select_sql.equals("")
|| s_update_sql == null
|| s_update_sql.equals("")) {
return affect_num;
}
try {
connDB();
ArrayList alist_data = dbinst.doQueryList(s_select_sql);
if (!alist_data.isEmpty() == b_next) {
affect_num = dbinst.doUpdate(s_update_sql);
}
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
return affect_num;
}
}
/**
* 根据传进来的sql获取一条数据库纪录中的单个数据值。
* @return String
* @roseuid 3DE57F6A0093
*/
public synchronized static int setUpdateByCheck(
String s_select_sql,
ArrayList alist_update_sql,
boolean b_next) {
int affect_num = 0;
if (s_select_sql == null
|| s_select_sql.equals("")
|| alist_update_sql == null
|| alist_update_sql.isEmpty()) {
return affect_num;
}
try {
connDB();
ArrayList alist_data = dbinst.doQueryList(s_select_sql);
if (!alist_data.isEmpty() == b_next) {
affect_num = dbinst.doUpdate(alist_update_sql);
}
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
return affect_num;
}
}
dongdongshu
2003-08-11
打赏
举报
回复
package book;
import book.DBJ;
import java.util.*;
public final class General {
/**
* 定义一个数据库句柄,还未实例化。
*/
private static DBJ dbinst;
private static int SOURCE_NUM = 0;
/**
* 初始化数据库对象实例,还未连接指定数据库。
* @roseuid 3DE57EFA02B9
*/
private static void initDbinst() {
if (SOURCE_NUM == 0) {
dbinst = null;
dbinst = new DBJ();
} else {
dbinst = null;
dbinst = new DBJ(SOURCE_NUM);
}
}
/**
* 构造函数,带参数。
* @roseuid 3DE57EFA02B9
*/
public General()
{
}
public General(int i_source)
{
SOURCE_NUM = i_source;
}
/*
* 设置数据源编号
*
*/
public static void setSource(int i_source_num)
{
SOURCE_NUM = i_source_num;
}
/**
* 连接数据库。
* @roseuid 3DE57EFA02B9
*/
public static void connDB() {
initDbinst();
dbinst.setConnection();
}
/**
* 提交数据库操作。
* @roseuid 3DE57EFA02B9
*/
public static void commit() {
if (dbinst != null) {
dbinst.setCommit();
}
}
/**
* 回滚数据库操作。
* @roseuid 3DE57EFA02B9
*/
public static void rollback() {
if (dbinst != null) {
dbinst.setRollback();
}
}
/**
* 关闭数据库连接。
* @roseuid 3DE57EFA02B9
*/
public static void closeDB() {
if (dbinst != null) {
dbinst.closeConnection();
}
}
/**
* 根据传进来的sql获取数据库纪录。
* @return ArrayList
* @roseuid 3DE57F6A0093
*/
public static ArrayList getPageQueryList(
String s_sql,
int pagecount,
int pagenum) {
ArrayList alist_data = null;
if (s_sql == null || s_sql.equals("")) {
alist_data = new ArrayList(1);
ArrayList alist_line = new ArrayList(2);
alist_line.add(0, "0");
alist_line.add(1, "0");
alist_data.add(0, alist_line);
return alist_data;
}
try {
connDB();
alist_data = dbinst.doPageQueryList(s_sql, pagecount, pagenum);
//closeDB();
} catch (Exception e) {
//closeDB();
System.out.println("DB error:" + e);
} finally {
if (alist_data == null) {
alist_data = new ArrayList(1);
ArrayList alist_line = new ArrayList(2);
alist_line.add(0, "0");
alist_line.add(1, "0");
alist_data.add(0, alist_line);
closeDB();
}
return alist_data;
}
}
/**
* 根据传进来的sql获取数据库纪录。
* @return ArrayList
* @roseuid 3DE57F6A0093
*/
public static Vector getPageQueryVector(
String s_sql,
int pagecount,
int pagenum) {
Vector vec_data = null;
if (s_sql == null || s_sql.equals("")) {
vec_data = new Vector(1);
Vector vec_line = new Vector(2);
vec_line.addElement("0");
vec_line.addElement("0");
vec_data.addElement(vec_line);
return vec_data;
}
try {
connDB();
vec_data = dbinst.doPageQueryVector(s_sql, pagecount, pagenum);
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
if (vec_data == null) {
vec_data = new Vector(1);
Vector vec_line = new Vector(2);
vec_line.addElement("0");
vec_line.addElement("0");
vec_data.addElement(vec_line);
}
return vec_data;
}
}
/**
* 根据传进来的sql获取数据库纪录。
* @return ArrayList
* @roseuid 3DE57F6A0093
*/
public static ArrayList getQueryList(String s_sql) {
ArrayList alist_data = null;
if (s_sql == null || s_sql.equals("")) {
alist_data = new ArrayList(0);
return alist_data;
}
try {
connDB();
alist_data = dbinst.doQueryList(s_sql);
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
if (alist_data == null) {
alist_data = new ArrayList(0);
}
return alist_data;
}
}
/**
* 根据传进来的sql获取数据库纪录。
* @return ArrayList
* @roseuid 3DE57F6A0093
*/
public static Vector getQueryVector(String s_sql) {
Vector vec_data = null;
if (s_sql == null || s_sql.equals("")) {
vec_data = new Vector(0);
return vec_data;
}
try {
connDB();
vec_data = dbinst.doQueryVector(s_sql);
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
if (vec_data == null) {
vec_data = new Vector(0);
}
return vec_data;
}
}
/**
* 根据传进来的sql获取一条数据库纪录中的单个数据值。
* @return String
* @roseuid 3DE57F6A0093
*/
public static String getOneValue(String s_sql) {
String s_return = "";
if (s_sql == null || s_sql.equals("")) {
return s_return;
}
ArrayList alist_data = null;
try {
connDB();
alist_data = dbinst.doQueryList(s_sql);
closeDB();
} catch (Exception e) {
closeDB();
System.out.println("DB error:" + e);
} finally {
if (alist_data != null && !alist_data.isEmpty()) {
ArrayList alist_line = (ArrayList) alist_data.get(0);
s_return = (String) alist_line.get(0);
}
if (s_return == null) {
s_return = "";
}
return s_return;
}
}
Morose
2003-08-11
打赏
举报
回复
up一下
dongdongshu
2003-08-11
打赏
举报
回复
TO:无名
应该是无效的连接占用资源,但我已经确确实实释放了啊~~
:(
TO flyshp(天堂雨)
是BEAN里用的的确是resultset
TO:sgdb(神天月晓)
有加这句啊·~
:(
dongdongshu
2003-08-11
打赏
举报
回复
TO:无名
应该是无效的连接占用资源,但我已经确确实实释放了啊~~
:(
TO flyshp(天堂雨)
是BEAN里用的的确是resultset
TO:sgdb(神天月晓)
有加这句啊·~
:(
op2618
2003-08-11
打赏
举报
回复
用ondemand吧!
sgdb
2003-08-11
打赏
举报
回复
rs.close();
rs=null;
呵呵,试试看吧!!
flyshp
2003-08-11
打赏
举报
回复
如果你的结果集调用的是 resultset 那就是问题的关键了!
nettman
2003-08-11
打赏
举报
回复
不知道!
帮你UP!
acefr
2003-08-11
打赏
举报
回复
早上好啊~
呵呵
按你这种说法。。。。
难道是释放的时候出错?然后导致无效的连接占用了资源?
加载更多回复(22)
echarts+vue——
散点
图+折线图——技能提升
echarts+vue——
散点
图+折线图——技能提升
matlab笔记——绘图篇——折线图+
散点
图+饼图+直方图+柱状图+箱线图+三维图+地图
matlab笔记——绘图篇——折线图+
散点
图+饼图+直方图+柱状图+箱线图+三维图+地图
Python数据可视化——
散点
图
本文记录了python中的数据可视化——
散点
图scatter,令x作为数据(50个点,每个30维),我们仅可视化前两维。labels为其类别(假设有三类)。这里的x就用random来了,具体数据具体
分
析。label设定为[1:20]->1, [21:35]->2, [36:50]->3,(python中数组连接方法:先强制转为list,用+,再转回array)用matplotlib的scatter
数据可视化1——R 语言+pycharm环境配置、 HTML、CSS、JavaScript
Web Programming Language
matlab绘制
散点
图——指定
散点
落于一个圆形区域内
matlab绘制
散点
图——指定
散点
落于一个圆形区域内
问题
: 在做海豚捕食沙丁鱼的仿真时,我们将沙丁鱼群看成了一个圆形区域内的
散点
,所以需要用matlab在一个圆形区域内绘制均匀
分
布的
散点
。 matlab代码实现 % 海豚进入前沙丁鱼群的初始状态 N=200;%沙丁鱼群中沙丁鱼的数量 % 沙丁鱼群圆形区域的圆心 x0=-100; y0=-100; % 沙丁鱼群圆形区域的实际半径 R=1...
Web 开发
81,092
社区成员
341,716
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章