【发布时间】:2011-01-14 17:13:34
【问题描述】:
MYSQL 中我的表中有 1652487 行。我想将一个字段对应的所有值复制到一个文件中。为此,我使用 jdbc 驱动程序在 netbeans 中编写了一个 java 程序。我无法一口气做到这一点。有出路吗 ?
[编辑]
我的代码:按下按钮时执行的操作:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try
{
File fo=new File("D:\\dmoz_externalpages.txt");
FileWriter fro=new FileWriter(fo);
BufferedWriter bro=new BufferedWriter(fro);
Connection con=null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dmozphp","root","");
PreparedStatement ps=con.prepareStatement("select externalpage from content_description");
ResultSet rs=ps.executeQuery();
while(rs.next())
{
bro.write(rs.getString(1));
bro.newLine();
bro.flush();
}
}
catch(Exception e)
{
System.out.println(e);
}
}
当我运行它时,我得到以下异常:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
【问题讨论】:
-
你的代码是什么样的,有什么问题?