We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › to sign or not to sign
Page Index Toggle Pages: 1
to sign or not to sign? (Read 838 times)
to sign or not to sign?
Feb 26th, 2007, 4:13am
 
Edited:

my apologies, delete this post if you wish. it was the webserver's fault.


i apologize if this is in the wrong forum, but i believe that it's a syntax problem for the JDBC driver that is causing my program to fail.

Code:
java.lang.SecurityException: illegal URL redirect
at sun.plugin.net.protocol.http.HttpUtils.followRedirects(Unknown Source)
at sun.plugin.cache.CachedFileLoader.download(Unknown Source)
at sun.plugin.cache.CachedFileLoader.load(Unknown Source)
at sun.plugin.cache.FileCache.get(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.connectWithCache(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


java is trying to access some URL, and since it isn't signed, it will not allow it. i only told it to load files in its own directory, though, so i'm confused. could it be from the sqlite.JDBC driver i'm using? here is my code (in java):

Code:
package test;
import java.sql.*;
import java.util.*;
import org.sqlite.JDBC;
import processing.core.*;

public class SQLiteTest extends PApplet {

private static final long serialVersionUID = 1L;
ArrayList tiles = new ArrayList();
int map[][] = new int[9][9];
int charX, charY;

public void setup()
{
 charX = charY = 4;
 size(288, 288);
 background(0);
 fill(255);
 grabTiles();
 grabMap();
}
   
public void draw()
{
 for(int a = 0; a < 9; a++)
   for(int b = 0; b < 9; b++)
     image((PImage) tiles.get(map[a][b]), b * 32, a * 32);

 noLoop();
}

public void 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");

   while(rs.next()){
     int id = rs.getInt("image_id");
     String desc = rs.getString("image_desc");
     String imgFile = rs.getString("image_file");
     PImage tmpImage = new PImage();
     tmpImage = loadImage(imgFile);
     System.out.println(id + ": " + desc);
     tiles.add(id, tmpImage);
   }
           
   rs.close();
   conn.close();
 } catch (Exception e) {
   e.printStackTrace();
 }  
}
   
public void grabMap()
{
 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 map__newbie_zone"
   + " where x >= " + (charX - 4)
   + " and x <= " + (charX + 4)
   + " and y >= " + (charY - 4)
   + " and y <= " + (charY + 4)
   + " order by x asc, y asc");

   while(rs.next()){
     int x = rs.getInt("x");
     int y = rs.getInt("y");
     int tile = rs.getInt("tile");
     map[x][y] = tile;
   }
 } catch(Exception e) {
   e.printStackTrace();
 }    
}

public static void main(String[] args) {
 PApplet.main(new String[] { "test.SQLiteTest" });
}    

}


Code:
package test;
import java.awt.BorderLayout;
import java.awt.Frame;
import processing.core.*;

public class ExampleFrame extends Frame {

private static final long serialVersionUID = 1L;

public ExampleFrame() {
 super("Embedded PApplet");
 setLayout(new BorderLayout());
 PApplet embed = new test.SQLiteTest();
 add(embed, BorderLayout.CENTER);
 embed.init();
}

}


should i just sign the applet, or is there a way to make sure that it knows that the sqlite db it's loading is file in the applet's directory? i've tried using "./curse.s3db" and loading images as "./"+imgFile ...

i'm just afraid that it's trying to access the s3db file from the client's computer rather than the directory that the .JAR resides in on the server side.

any help is greatly appreciated, as this error has me stumped. i don't see why it has a problem trying to load a file that resides on the server, since i've done plenty of loadImage calls that worked just fine.. that's why i think it has to be the SQLite method, but i am unsure.
Re: to sign or not to sign?
Reply #1 - Feb 26th, 2007, 4:25am
 
i'm going to try listing the SQLite database file as "jdbc:sqlite:http://curse.bravehost.com/curse.s3db" and see if it does anything. Tongue

Edited:

nope, same problem. gotta be signed i guess.. though i don't see why.
Re: to sign or not to sign?
Reply #2 - Feb 26th, 2007, 7:56am
 
still getting the error, even with a signed applet. i'm stumped.
Re: to sign or not to sign?
Reply #3 - Feb 26th, 2007, 8:22am
 
ok, i'm an idiot. i'll put a notice on my first post.. it's the stupid free webserver i'm using restricting the applet's access further than usual.

i switched to a 6hr-lifespan tomcat server from eatj.com and a barebones demo ran just fine, with no errors.

sorry for all the confusion.. but one upside is that i will be posting a simple tutorial for signing your java applets with an unofficial certificate for testing purposes.

meh. Tongue
Page Index Toggle Pages: 1