StelsDBF java.lang.OutOfMemoryError: Java heap space

不羁岁月 提交于 2019-12-25 05:24:08

问题


I am using a evaluation version of StelsDBF JDBC Driver 5.2 I have a dbf file with 8302 rows and 43 cols 5mb and StelsDBF seems not working. StelsDBF works fine with other smaller files.

My query

select codi,descrip from \"DATA.DBF\" limit 10

When I try to get the results I get the following

Exception in thread "'DATA.DBF' producer" java.lang.OutOfMemoryError: Java heap space
    at jstels.database.b.d.if(Unknown Source)
    at jstels.database.b.e.do(Unknown Source)
    at jstels.jdbc.dbf.a.b.a(Unknown Source)
    at jstels.jdbc.common.h2.OperationTable$a.do(Unknown Source)
    at jstels.jdbc.common.h2.OperationTable$a.a(Unknown Source)
    at jstels.utils.b.b$a.run(Unknown Source)

I added the parameter &dbPath=D:/juan/sync/syncro_db&tempPath=C:/Temp and get the next

Exception in thread "'DATA.DBF' producer" java.lang.OutOfMemoryError: Java heap space
    at jstels.database.b.d.if(Unknown Source)
    at jstels.database.b.e.do(Unknown Source)
    at jstels.jdbc.dbf.a.b.a(Unknown Source)
    at jstels.jdbc.common.h2.OperationTable$a.do(Unknown Source)
    at jstels.jdbc.common.h2.OperationTable$a.a(Unknown Source)
    at jstels.utils.b.b$a.run(Unknown Source)
java.sql.SQLException: [StelsDBF JDBC driver] Can't load the file 'DATA.DBF' to H2 database. Error was: Time is out in 'consumer' thread
    at jstels.jdbc.common.h2.OperationTables.loadTable(Unknown Source)
    at jstels.jdbc.common.h2.g.a(Unknown Source)
    at jstels.jdbc.common.h2.g.executeQuery(Unknown Source)
    at com.rhemsolutions.customer.TestStelsDbf.main(TestStelsDbf.java:27)

I added VM arguments to my IDE too -XX:MaxPermSize=512m -Xmx2048m but get the same exceptions.

Here is my code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TestStelsDbf {

    public static void main(String[] args) {
        String drive = "D:/juan/dbf";

        try {
            Class.forName("jstels.jdbc.dbf.DBFDriver2");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
          try {
//          Connection conn = DriverManager.getConnection("jdbc:jstels:dbf:"+drive+"?extension=.DBF");
//            Connection conn = DriverManager.getConnection("jdbc:jstels:dbf:"+drive+"?extension=.DBF&dbPath=D:/juan/sync/syncro_db&tempPath=C:/Temp");
              Connection conn = DriverManager.getConnection("jdbc:jstels:dbf:"+drive+"?extension=.DBF&dbInMemory=false&tempPath=C:/Temp");

            String cli = "select codi,descrip from \"DATA.DBF\" limit 10";
            Statement stmt = conn.createStatement();

            ResultSet rs = stmt.executeQuery(cli);
            for (int j = 1; j <= rs.getMetaData().getColumnCount(); j++) {
                System.out.print(rs.getMetaData().getColumnName(j) + "\t");
            }
            System.out.println();
            while (rs.next()) {
                for (int j = 1; j <= rs.getMetaData().getColumnCount(); j++) {
                  System.out.print(rs.getObject(j) + "\t");
                }
                System.out.println();
              }
             rs.close();
             stmt.close();
             conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

Sorry for too many exceptions. Could you help me? Thanks in advance.


回答1:


IMHO, you need to move the synchrobase out of the Java heap.

I notice you already tried with a persistent synchrobase. Two suggestions:

1) Do not use the root of a drive, but a directory. Move your .DBF files there.

String drive = "D:/myDB";

2) Try with a temporary synchrobase.

Connection conn = DriverManager.getConnection("jdbc:jstels:dbf:"+drive+"?extension=.DBF&dbInMemory=false&tempPath=C:/Temp");


来源:https://stackoverflow.com/questions/18326959/stelsdbf-java-lang-outofmemoryerror-java-heap-space

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!