What do I have to do to avoid error of “out of mem

2019-02-17 08:02发布

What do I have to do to avoid error of "out of memory", when connection by jdbc with sqlite3 database?

java.sql.SQLException: out of memory
at org.sqlite.DB.throwex(DB.java:288)
    at org.sqlite.NestedDB._open(NestedDB.java:73)
    at org.sqlite.DB.open(DB.java:77)
    at org.sqlite.Conn.<init>(Conn.java:88)
    at org.sqlite.JDBC.connect(JDBC.java:64)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at action.Actions.<init>(Actions.java:18)
    at controler.ClientControler.<init>(ClientControler.java:14)
    at main.Main.main(Main.java:20)


Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite:clients.db");

8条回答
劫难
2楼-- · 2019-02-17 08:59

Like DarkCthulhu already mentioned you must not have any spaces in the path to your database file. This applies even if you declared a relative path to it (like in your case). I bet the path to your project contains one or more spaces.

You can either declare it with its full path and spaces escaped, or by changing your project location to a path without any spaces!

查看更多
冷血范
3楼-- · 2019-02-17 09:02

Yes, in case when file not found it generates such strange exception "out of memory". In Eclipse IDE instead specifying database name and path separately, put database file name into field: Database location.

Example: Database location: c:\temp\test.db

查看更多
登录 后发表回答