Hi all

 

The function below is running out of memory. Can anyone please tell me why?

 

 

 

    private void importGeoIP2()

    {

        JFileChooser fc = new JFileChooser();   

        int returnVal = fc.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION)

        {

            String line = "";

            try

            {

                BufferedReader in = new BufferedReader(new FileReader(fc.getSelectedFile()));

                int i = 0;

                while ((line = in.readLine()) != null)

                {

                    i++;

                    String[] split = line.split(",");

                    if (split.length == 6)

                    {

                        try

                        {

                            PreparedStatement stmt = context.getConnection().prepareStatement("insert into geoip (start_ip, end_ip, start, end, country_id) values (?,?,?,?,?)");

                            stmt.setString(1, strip(split[0]));

                            stmt.setString(2, strip(split[1]));

                            stmt.setString(3, strip(split[2]));

                            stmt.setString(4, strip(split[3]));

                            stmt.setInt(5, -1);

                            stmt.execute();

                            if (i % 100 == 0)

                            {

                                System.out.println(i + "");

                            }

                        }

                        catch (SQLException sqle)

                        {

                            JOptionPane.showMessageDialog(null, "Error while importing file: " + sqle.getMessage());                                                                           

                        }

                    }                    

                }

            }

            catch (FileNotFoundException fnfe)

            {

                JOptionPane.showMessageDialog(null, "Cannot import file: " + fnfe.getMessage());                                           

            }

            catch (IOException ioe)

            {

                JOptionPane.showMessageDialog(null, "Error while importing file: " + ioe.getMessage());                                                           

            }

        }       

    }

 

 

Hendre Louw

Java Consultant

Skype: hendrel

 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
-~----------~----~----~----~------~----~------~--~---

Reply via email to