开发者

SQLite database connection problems java/eclipse

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


public class GestorBase
{
private  ResultSet resultset;
private static  Connection con;
private  Statement sentencia;

public static void main(String[] args) throws SQLException, ClassNotFoundException
    {开发者_高级运维

    Class.forName("org.sqlite.JDBC");

    con = DriverManager.getConnection("jdbc:sqlite:db/Freepark.sqlite");

    System.out.println("error al buscar la base de datos");

    Statement sentencia = con.createStatement();

    String query = "SELECT * FROM Restaurantes";

    ResultSet resultset = sentencia.executeQuery(query);


    while(resultset.next())
        {
            String nombre = resultset.getString("NOMBRE");
            String calle = resultset.getString("CALLE");
            int codigo = resultset.getInt("CODIGO");
            System.out.println("Codigo de restaurante: "+ codigo +" Nombre de restaurante: "+ nombre +" Calle del restaurante: "+ calle);
        }



    }
}

I am trying to connect to a sqlite database in Java but I get this console log:

Exception in thread "main" 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 GestorBase.main(GestorBase.java:21)


How much data are you pulling out here?

You could try increasing the memory alloted to the java VM

java -Xmx256m ...

The default is only 64Mb.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜