在线等!Ibatis 与 Tomcat问题!!!

LinApex 2011-09-29 05:41:33
我的Mysql数据库有10个数据库,每个数据库有 100张同样的表。

Service 层 Sql语句

public synchronized List<PosOrder> executeFindPayMoneyList(String where)
throws Exception {
List<PosOrder> orderList = new ArrayList<PosOrder>();
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("status", "1");
paramMap.put("delivery", "0");
paramMap.put("buyType", "1");
paramMap.put("where", where);
//循环10个数据库
for(int i = 0;i<10;i++){
//循环100张表
for(int j = 0;j<100;j++){
int m = j /10;
int n = j % 10;
paramMap.put("dataBaseName", "pay" + i);
paramMap.put("tableName", "t_pos_order_" + m+n);
orderList.addAll(client2.queryForList(
"findAllOrderByStatusAndDelivery", paramMap));
}
}


return orderList;
}

我的Xml配置文件

<select id="findAllOrderByStatusAndDelivery" resultMap="PosOrderResult" resultClass="PosOrder" parameterClass="java.util.Map"> select * from $dataBaseName$.$tableName$ where 1=1 and F_disable = 0 and F_status = $status$ and F_delivery = $delivery$ and F_buy_type = $buyType$ $where$ </select>

我执行 executeFindPayMoneyList(null)方法的时候, 访问数据库的Sql语句是

select * from pay0.t_pos_order_00 where 1=1 and F_disable = 0 and F_status = 1 and F_delivery = 0 and F_buy_type = 1

select * from pay0.t_pos_order_01 where 1=1 and F_disable = 0 and F_status = 1 and F_delivery = 0 and F_buy_type = 1

select * from pay0.t_pos_order_02 where 1=1 and F_disable = 0 and F_status = 1 and F_delivery = 0 and F_buy_type = 1

...

然后 下一个数据库 ,注意 pay0 改成 pay1了

select * from pay1.t_pos_order_00 where 1=1 and F_disable = 0 and F_status = 1 and F_delivery = 0 and F_buy_type = 1

select * from pay1.t_pos_order_01 where 1=1 and F_disable = 0 and F_status = 1 and F_delivery = 0 and F_buy_type = 1

select * from pay1.t_pos_order_02 where 1=1 and F_disable = 0 and F_status = 1 and F_delivery = 0 and F_buy_type = 1

最后一直到

select * from pay9.t_pos_order_99 where 1=1 and F_disable = 0 and F_status = 1 and F_delivery = 0 and F_buy_type = 1



每次一个请求都会启动一个新的线程,来这样子访问数据库,请求多了,我这里 Tomcat就挂掉了,查看 Tomcat Logs日志记录的话,说是内存溢出了。

这是记录:
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/JXCManager] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/JXCManager] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1bfefb]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@13ada]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@bed4c8]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@8398e7]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1bfefb]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1ab6c1c]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@146ac5a]) and a value of type [com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil.FactorySettings] (value [com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil$FactorySettings@12b9f79]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@f2db2d]) and a value of type [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl] (value [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@13a356]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1bfefb]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1489ea3]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@bed4c8]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@a6faa9]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@928739]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1ebe8ec]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1bfefb]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@108f060]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@146ac5a]) and a value of type [com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil.FactorySettings] (value [com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil$FactorySettings@1dd5a3d]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@f2db2d]) and a value of type [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl] (value [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@14f7a86]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1bfefb]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@f4fb44]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Sep 29, 2011 12:58:09 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/JXCManager] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1bfefb]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@19c4364]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
有朋友有解决方案吗?
...全文
349 22 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
wtc860104 2011-09-30
  • 打赏
  • 举报
回复
我的Mysql数据库有10个数据库,每个数据库有 100张同样的表。
你这是什么需求?为什么要相同的表?能给解释一下么?
webrobot 2011-09-30
  • 打赏
  • 举报
回复
需求?思路貌似有问题
aqqbjlgu 2011-09-30
  • 打赏
  • 举报
回复
弄个视图!
aqqbjlgu 2011-09-30
  • 打赏
  • 举报
回复
弄个视图!
游一游走一走 2011-09-30
  • 打赏
  • 举报
回复
按库名及表名(一定是排序过)查询出每个表符合的总条数,根据分页信息可以确定它在哪个表的哪些记录,取出指定数据应该可以,别把数据全取出来丢内存不挂掉才异常
德薄才浅 2011-09-30
  • 打赏
  • 举报
回复
这么大的数据量而且还是并发tomcat是扛不住的,大型的数据处理一般都是分布式系统,你应该考虑分布式!
德薄才浅 2011-09-30
  • 打赏
  • 举报
回复
这么大的数据量而且还是并发tomcat是扛不住的,大型的数据处理一般都是分布式系统,你应该考虑分布式!
德薄才浅 2011-09-30
  • 打赏
  • 举报
回复
这么大的数据量而且还是并发tomcat是扛不住的,大型的数据处理一般都是分布式系统,你应该考虑分布式!
LinApex 2011-09-30
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 zyz1985 的回复:]

思路不是给你了么?你是要代码吧
Java code


public static void main(String[] args) throws Exception {
int[][] rowCount = new int[10][100];
for (int i = 0; i < rowCount.length; i++) {
……
[/Quote]

朋友,你的思路给了我思路,一个分页的思路,首先,我会count一下每个表的数据数量,当数量大于或等于 start 数之后 ,保存当前数据库和当前表,然后 从保存的数据库和当前表开始查,limit 数量是否大于 pageSize 如果不大于 则继续查,大于则返回。
游一游走一走 2011-09-30
  • 打赏
  • 举报
回复
思路不是给你了么?你是要代码吧


public static void main(String[] args) throws Exception {
int[][] rowCount = new int[10][100];
for (int i = 0; i < rowCount.length; i++) {
for (int j = 0, length = rowCount[i].length; j < length; j++) {
rowCount[i][j] = i + j + 10;// "SELECT COUNT(*) FROM dbName"+i+".tableName"+j+" WHERE condition"
if (i == 0 && j < 20) {
System.out.print(rowCount[i][j] + " ");
}
}
}
System.out.println();
int currentPage = 50;// 前台值
int pageSize = 20;// 前台值
int start = currentPage * pageSize;
int end = 0;
boolean isOverTwoTable = false;
Integer dbIndex = null;
Integer tableIndex = null;
Integer overDbIndex = null;
Integer overTableIndex = null;
outter: for (int i = 0; i < rowCount.length; i++) {
for (int j = 0, length = rowCount[i].length; j < length; j++) {
if (rowCount[i][j] < start) {
start = start - rowCount[i][j];
} else {
if (rowCount[i][j] > start + pageSize) {// 没有跨表分页
dbIndex = new Integer(i);
tableIndex = new Integer(j);
} else {// 有跨表分页,简化处理假设每个表数据量>10
isOverTwoTable = true;
dbIndex = new Integer(i);
tableIndex = new Integer(j);
end = start + pageSize - rowCount[i][j];
if ((j + 1) > length) {
overDbIndex = new Integer(i + 1);
overTableIndex = new Integer(0);
} else {
overDbIndex = new Integer(i);
overTableIndex = new Integer(j + 1);
}
}
break outter;
}
}
}
if (isOverTwoTable) {
System.out.println("SELECT * FROM dbName" + dbIndex + ".tableName"
+ tableIndex + " WHERE condition limit " + start + ","
+ pageSize);
System.out.println("SELECT * FROM dbName" + overDbIndex
+ ".tableName" + overTableIndex + " WHERE condition limit "
+ 0 + "," + end);
} else {
System.out.println("SELECT * FROM dbName" + dbIndex + ".tableName"
+ tableIndex + " WHERE condition limit " + start + ","
+ pageSize);
}
}

LinApex 2011-09-30
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 zyz1985 的回复:]

按库名及表名(一定是排序过)查询出每个表符合的总条数,根据分页信息可以确定它在哪个表的哪些记录,取出指定数据应该可以,别把数据全取出来丢内存不挂掉才异常
[/Quote]

就是这里出现了问题,所以需要解决方案,有思路吗?
LinApex 2011-09-30
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 webrobot 的回复:]

需求?思路貌似有问题
[/Quote]

有何高见?
LinApex 2011-09-30
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 wtc860104 的回复:]

我的Mysql数据库有10个数据库,每个数据库有 100张同样的表。
你这是什么需求?为什么要相同的表?能给解释一下么?
[/Quote]

我的数据库是 分库分表的,插入一条数据,根据 算法运算,然后插入到哪个数据库哪张表
如:前台 注册一个用户,在后台处理的时候,对这个用户资料进行算法运算,得出结果是 pay3.t_order_33这张表以后,然后进行插入到这 pay3.t_order_33 这个表中。

相同的表结构可以拆分,可以进行分布式,很方便。
LinApex 2011-09-29
  • 打赏
  • 举报
回复
速度顶起!
LinApex 2011-09-29
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 scrack 的回复:]

其实你可以用存储过程的 这样在应用里面做 压力确实比较大的
[/Quote]
存储过程,可以考虑,我这里出现的问题是 Tomcat挂掉了,有在 程序中解决的方法吗、?
LinApex 2011-09-29
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 sun_mingtao 的回复:]

请问你是要测试你的tomcat的性能吗?
[/Quote]

不是,我在开发项目,请问有解决思路吗?
scrack 2011-09-29
  • 打赏
  • 举报
回复
其实你可以用存储过程的 这样在应用里面做 压力确实比较大的
德薄才浅 2011-09-29
  • 打赏
  • 举报
回复
请问你是要测试你的tomcat的性能吗?
LinApex 2011-09-29
  • 打赏
  • 举报
回复
速度,在线等!
LinApex 2011-09-29
  • 打赏
  • 举报
回复
速度,在线等!
加载更多回复(2)

67,550

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧