求助,关于java链接mysql(数据量较大)
2012-05-05 00:00
260 查看
背景:
把一个很大的xml信息存到数据库里面,xml文件大概有1G,在小数据量下跑过程序,已经没有问题,但是一用大数据量的文件跑就悲剧了,报的是这个错:
-----------------------------------------------------------------------------------------------------------------------------
connect failed!
Exception is: The driver was unable to create a connection due to an inability to establish the client portion of a socket.
This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable.
For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.
For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).----------------------------------------------------------------------------------------关于数据库操作部分的代码:
public int selectCount(String dbName , String tableName, String condition) throws InterruptedException
{
String sql = "select count(*) from " +tableName +" where " + condition;
ResultSet dbresult = null;
connectDB(dbName);
int ret = 0;
try{
dbstate = dbconn.createStatement();
dbresult = dbstate.executeQuery(sql);
if(dbresult.next())
ret = dbresult.getInt(1);
}catch(SQLException e) {
printerr("sql is:" + sql);
printerr(e.getMessage());
}
closeDB();
return ret;
}
所有其他操作与之类似,要进行操作前链接,操作完close, 看网上的解答,大部分是说将mysql的最大连接数改大,我将其改大了之后,也只是将处理两千条之后报错改成了处理三千条之后报错而已,目前还没有引进多线程,整个程序是单线程的状态,目前我的mysql最大连接数是1000,感觉已经很大了,可是智能处理到给目标数据库增加4000条左右的数据。感觉单纯通过改大连接数来达到这个效果是个治标不治本的方法。 实在是没辙了,有没有人经历过类似的错误,想问一下有没有其他的解决方案。求各位大神分享方法
把一个很大的xml信息存到数据库里面,xml文件大概有1G,在小数据量下跑过程序,已经没有问题,但是一用大数据量的文件跑就悲剧了,报的是这个错:
-----------------------------------------------------------------------------------------------------------------------------
connect failed!
Exception is: The driver was unable to create a connection due to an inability to establish the client portion of a socket.
This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable.
For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.
For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).----------------------------------------------------------------------------------------关于数据库操作部分的代码:
public int selectCount(String dbName , String tableName, String condition) throws InterruptedException
{
String sql = "select count(*) from " +tableName +" where " + condition;
ResultSet dbresult = null;
connectDB(dbName);
int ret = 0;
try{
dbstate = dbconn.createStatement();
dbresult = dbstate.executeQuery(sql);
if(dbresult.next())
ret = dbresult.getInt(1);
}catch(SQLException e) {
printerr("sql is:" + sql);
printerr(e.getMessage());
}
closeDB();
return ret;
}
所有其他操作与之类似,要进行操作前链接,操作完close, 看网上的解答,大部分是说将mysql的最大连接数改大,我将其改大了之后,也只是将处理两千条之后报错改成了处理三千条之后报错而已,目前还没有引进多线程,整个程序是单线程的状态,目前我的mysql最大连接数是1000,感觉已经很大了,可是智能处理到给目标数据库增加4000条左右的数据。感觉单纯通过改大连接数来达到这个效果是个治标不治本的方法。 实在是没辙了,有没有人经历过类似的错误,想问一下有没有其他的解决方案。求各位大神分享方法
相关文章推荐
- 关于Java调用批处理命令向mysql导入数据的中文乱码有关问题
- java 链接mysql 产生500W数据模拟生成环境
- java jdbc 链接mysql插入数据中文显示乱码
- 关于ssh javaweb 项目插入或者更新数据后 mysql 数据乱码的问题
- 关于Java程序(WEB程序)数据提交到Mysql,Mysql数据出现乱码的问题
- 关于Mysql数据库longblob格式数据的插入com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V问题分析
- Java链接Mysql数据代码
- Java 链接Mysql 数据库时使用变量插入数据方法
- Java 链接MYSQL 显示数据所有记录
- 工作随笔——肆(利用Navicat管理MySql时关于较大数据备份导入问题)
- mysql中关于数据的编码问题
- java mysql分页查询大量数据,批量插入
- MySQL数据类型与java类型的匹配关系
- 关于mysql处理百万级以上的数据时如何提高其查询速度的方法
- MySQL\Hibernate\Java数据类型映射关系
- Mysql,Oracle,Java数据类型对应
- java 链接Mysql的一个通用类
- JAVA_关于JAVA中的数据类型
- 关于mysql处理百万级以上的数据时如何提高其查询速度的方法
- Java连接MySQL报错:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver(内附jre下载链接)