SQLite to load a map

i've been using the SQLite JDBC driver in order to load maps and filenames from an SQLite *.s3db file. locally, it works fine.

as soon as i upload it to my webserver (which is on my local network, controlled by me), it just blanks out and sits there.

java.lang.NoClassDefFoundError

at org.sqlite.Conn.<init>(Conn.java:11)

at org.sqlite.JDBC.connect(JDBC.java:38)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at MapPanel.grabTiles(MapPanel.java:40)

at MapPanel.setup(MapPanel.java:22)

at processing.core.PApplet.handleDisplay(PApplet.java:1281)

at processing.core.PGraphics.requestDisplay (PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1450)

at java.lang.Thread.run(Unknown Source)

the particular chunk of code in question is this:

publicvoid grabTiles()

{

try{

String fileName ="curse.s3db";

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

Connection conn = DriverManager.getConnection("jdbc:sqlite:"+fileName);

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select * from tiles__map");

...

and the line in particular:

Connection conn = DriverManager.getConnection("jdbc:sqlite:"+fileName);

note - "fileName" is "curse.s3db" .. i have also tried "./curse.s3db" and various urls referencing the db file on the remote server or my local hard drive, depending on the test.

this even happens when i run the applet in an index.html file in my own local hard drive, in the same directory as everything else that should be necessary.

again.. locally, everything works like magic. as soon as i try to embed it, it breaks.

is there some parameter i need to pass to it in the HTML tag that i don't know about in order to tell it where to find everything else?

i've tried signing the applet, though i doubt it should be necessary to load files from the same directory the applet is being run from on the remote server. i'm not touching anything client side.

any help would be greatly appreciated, as i really want to get an SQLite database file working with my game. for what i need to use it for, it is a much better alternative to MySQL or similar packages.

the directory on the remote server is basically like this:

images/

curse.s3db

curse.jar

index.html

..same as it is on my local machine.. and if i were to double-click the .jar on my local machine, it runs fine without any errors. as soon as i try to run it remotely (and load the files remotely rather than from my own pc) it doesn't know where to look for curse.s3db.

[3047 byte] By [haliphaxa] at [2007-11-26 19:42:57]
# 1
The PC where has invoking the applet, will have the jar files for the database ?, or , are included within the applet ?
tyrant4Javaa at 2007-7-9 22:25:33 > top of Java-index,Other Topics,Java Game Development...
# 2

edit: i misunderstood your question when i first typed this message, but it still adds more information. to answer your question, though: the library for native java access to sqlite's JDBC driver was extracted and placed in the curse.jar archive. i can run a local test running it as an application (and not as an applet embedded in a webpage) without any driver files being in my working directory and the native code will take care of everything. however, this is what is not working on the server side tests.

the web server holds everything. literally. everything.

the client simply accesses the HTML file and is given the applet. the client does not (or at least should not) need to have the applet, any of the image files, or the DB file on their computer.

so.. the DB file will be loaded from the server by the applet. the program has no trouble loading files from the working directory of the applet on the sever side (the images/ folder holds *.jpg files that display just fine). it has to be something to do with the path that jdbc:sqlite: uses by default..

haliphaxa at 2007-7-9 22:25:33 > top of Java-index,Other Topics,Java Game Development...
# 3

would it matter if i put the native sqlite.jdbc driver's *.jar file in the working directory of curse.jar on the server?

if i did so, would i need to specify somehow that curse.jar depends on the native sqlite.jdbc's *.jar?

btw.. it's "curse.jar" because my project is CURSE - (C)ooperative (U)niversal (R)ole-playing and (S)trategy (E)ngine. just a little info. :)

haliphaxa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 4
ok... look... an applet is executed on client machine, then the jar files that needthey must beincluded on applet (jar file) or on classpath of the JVM on client.we agree in that ?
tyrant4Javaa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 5
This may be works ...Indicate in the MANIFEST the files (.jar) than the applet need it for execute.In this link you can find the info : http://java.sun.com/j2se/1.4.2/docs/guide/extensions/versioning.html
tyrant4Javaa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 6

> ok... look...

>

> an applet is executed on client machine, then the jar

> files that needthey must beincluded on applet

> (jar file) or on classpath of the JVM on client.

>

> we agree in that ?

we agree. however, i have already taken care of that. it's just that the libraries are not in a .jar inside curse.jar, but rather in their respective directories inside curse.jar.

haliphaxa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 7
Ok. And it works now the applet?
tyrant4Javaa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 8
no, it does not work. i get the same error. i have also tried including them as *.jar files inside curse.jar, and also placing their *.jar files inside the working directory of curse.jar.. none of it makes any difference, i always get the same error.
haliphaxa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 9

i fixed the error.

i had to use the Extension method inside the MANIFEST.MF file in order to get it to work. i also had to sign all *.jar files involved. here is my manifest file:

Manifest-Version: 1.0

Main-Class: MapPanel

sqlite-Extension-Name: org.sqlite

sqlite-Implementation-URL: http://192.168.0.4/curse/sqlite.jar

i'm testing this on a webserver on my local network for ease of configuration. the interesting thing is that i did not have to do this in order to get any of my other libraries to work.. it's something specific to the sqlite.JDBC driver.

either way, it works just fine now. i have to decide if the native driver will give me the speed necessary to animate a map.

thank you for pointing me in the right direction with the manifest!!

haliphaxa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 10

on second thought.. no, it doesn't work. it now properly loads the JDBC driver, but i cannot find a way to tell JDBC to look for the database on the remote server.

the current working directory for the applet defaults to my Desktop folder, and that is where JDBC looks for curse.s3db.

i am going to try using "jdbc:sqlite:http://192.168.0.4/curse/curse.s3db" and see if it makes any bit of difference.. although that means that the database will probably be cached locally and read.

that's fine with me, though. i don't want any of the client apps changing the database at all.. that is what the server daemon will be for.

i'll let you know how using http:// works out.

haliphaxa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 11

using the following code

Connection conn = DriverManager.getConnection("jdbc:sqlite:http://192.168.0.4/curse/curse.s3db");

now produces this error:

java.sql.SQLException: out of memory

at org.sqlite.DB.throwex(DB.java:252)

at org.sqlite.NestedDB.open(NestedDB.java:47)

at org.sqlite.Conn.<init>(Conn.java:36)

at org.sqlite.JDBC.connect(JDBC.java:38)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at MapPanel.grabTiles(MapPanel.java:39)

at MapPanel.setup(MapPanel.java:22)

at processing.core.PApplet.handleDisplay(PApplet.java:1281)

at processing.core.PGraphics.requestDisplay(PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1450)

at java.lang.Thread.run(Unknown Source)

MapPanel.grabTiles(MapPanel.java:39) is the same as when it was :40.. the code has just changed slightly and so has the placement of that statement.

haliphaxa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 12
i think than that don't work .... this SQLite is like a MS Access Database ? , if this is right , you cannot connect like a client/server, because that DB is not a DB Server. Locally, works. But remote... not.
tyrant4Javaa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...
# 13
i just think that sucks, since if it were mysql, "localhost" would point to the remote server and not the client pc.. and if it were a .jpg file, "./images/blah.jpg" would refer to the remote server rather than the client pc.what a gip.
haliphaxa at 2007-7-9 22:25:34 > top of Java-index,Other Topics,Java Game Development...