views:

46

answers:

1

Hi,

There are 1652487 rows in my table in MYSQL. I want to copy all the values corresponding to one field into a file. I wrote a java program in netbeans using jdbc driver for this. I'm unable to do this at one go. Is there a way out ? < Is there any limit on the number of rows one can select >

[ EDIT ]

my code : action performed when a button is pressed :

 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);
        }

    }       

when i run this , i get the following exception :

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
+2  A: 

There is no MySQL limit on this. My strong guess is you're limited by the memory on the client side.

I've been able to export entire tables with >25mil rows without problems before.

If you want to export the data the quickest way, use SELECT INTO OUTFILE or give Maatkit a go.

Artem Russakovskii
i found that i could do this when i just execute that command < but it displayed them in 82625 pages each having about 20 rows > , which meant that manually copying this data into a file would be time consuming.. So , i wrote a program to automate this writing to a file. and when i executed it , i got the exception i mentioned above < in my EDIT >
trinity
Thanks , i got just what i needed .( SELECT INTO OUTFILE option )
trinity