我正在使用StelsDBF JDBC 驱动程序 5.2的评估版 我有一个 dbf 文件,它有 8302 行和 43 列 5mb,StelsDBF 似乎无法正常工作。StelsDBF 适用于其他较小的文件。
我的查询
select codi,descrip from \"DATA.DBF\" limit 10
当我尝试获得结果时,我得到以下结果
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)
我添加了参数&dbPath=D:/juan/sync/syncro_db&tempPath=C:/Temp并得到下一个
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)
我也在我的 IDE 中添加了 VM 参数-XX:MaxPermSize=512m -Xmx2048m但得到了相同的异常。
这是我的代码:
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();
}
}
}
抱歉,例外太多。你可以帮帮我吗?提前致谢。