JoSQL reposted

S

Sharp Tool

Hi,

I'm trying to learn how to use a new tool called JoSQL available at the
Source Forge project. Link: http://josql.sourceforge.net/

In the main file, the query.parse() appears to have trouble finding
the person class. Can anyone shed some light on this?

/* PERSON CLASS*/

package classfiles;

public class Person{
String name;

public Person (String name){
this.name = name;
}

public String toString(){
return name;
}
}

/* JAVASQL CLASS - MAIN FILE */
package classfiles;

import java.util.*;
import org.josql.*;

public class JavaSQL
{
public static void main (String[] args){
JavaSQL jSQL = new JavaSQL();
jSQL.start();
}

public void start(){
Person p1 = new Person ("foo");
Person p2 = new Person ("bar");
List list = new ArrayList();
list.add(p1);
list.add(p2);

try{
Query query = new Query();
query.parse("SELECT * FROM classfiles.Person ORDER BY name"); //ERROR
APPEARS TO BE HERE!
QueryResults rs = query.execute(list);
for(Iterator i = rs.getResults().iterator(); i.hasNext();){
Person p = (Person)i.next();
System.out.println(p);
}
}
catch(Exception e){
e.printStackTrace();
}
}
}

/*Run-time error message */
org.josql.QueryParseException: Unable to load FROM class: classfiles.Person
at org.josql.Query.parse(Query.java:1783)
at classfiles.JavaSQL.start(JavaSQL.java:25)
at classfiles.JavaSQL.main(JavaSQL.java:11)
Caused by: java.lang.ClassNotFoundException: classfiles.Person
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.josql.Query.parse(Query.java:1779)
... 2 more
Press any key to continue...


Any help appreciated.
Sharp
 
C

Christian

Hi Sharp,

Sharp said:
Hi,

I'm trying to learn how to use a new tool called JoSQL available at the
Source Forge project. Link: http://josql.sourceforge.net/

In the main file, the query.parse() appears to have trouble finding
the person class. Can anyone shed some light on this?

/* PERSON CLASS*/

package classfiles;

public class Person{
String name;

public Person (String name){
this.name = name;
}
[more code]
/*Run-time error message */
org.josql.QueryParseException: Unable to load FROM class: classfiles.Person
at org.josql.Query.parse(Query.java:1783)
at classfiles.JavaSQL.start(JavaSQL.java:25)
[stack trace]
Press any key to continue...

I had success to run this code, but I had to change the visibility of
Person.name to public.

I had the following envrionment:

../classfiles
../classfiles/Person.class
../classfiles/JavaSQL.class
../JoSQL-1.0.jar
../3rd-party-jars/gentlyWEB-utils-1.1.jar

I have used the JVM from Sun (1.5.0_02), and I called it with:

$ java -cp .:./3rd-party-jars/gentlyWEB-utils-1.1.jar:./JoSQL-1.0.jar
classfiles/JavaSQL

The (correct) result was:

bar
foo

Hope that helps,

Christian
 
S

Sharp Tool

Christian said:
Hi Sharp,

Sharp said:
Hi,

I'm trying to learn how to use a new tool called JoSQL available at the
Source Forge project. Link: http://josql.sourceforge.net/

In the main file, the query.parse() appears to have trouble finding
the person class. Can anyone shed some light on this?

/* PERSON CLASS*/

package classfiles;

public class Person{
String name;

public Person (String name){
this.name = name;
}
[more code]
/*Run-time error message */
org.josql.QueryParseException: Unable to load FROM class: classfiles.Person
at org.josql.Query.parse(Query.java:1783)
at classfiles.JavaSQL.start(JavaSQL.java:25)
[stack trace]
Press any key to continue...

I had success to run this code, but I had to change the visibility of
Person.name to public.

I had the following envrionment:

./classfiles
./classfiles/Person.class
./classfiles/JavaSQL.class
./JoSQL-1.0.jar
./3rd-party-jars/gentlyWEB-utils-1.1.jar

I have used the JVM from Sun (1.5.0_02), and I called it with:

$ java -cp .:./3rd-party-jars/gentlyWEB-utils-1.1.jar:./JoSQL-1.0.jar
classfiles/JavaSQL

The (correct) result was:

bar
foo

Hope that helps,

Christian

Thanks it helped.

My problem was I put the *.jar files in the jdk/jre/ext/
and the java and class files in a desktop folder.

I made sure everything pointed in the right direction but still doesn't
work.
You want to give it a try?

Sharp
 
C

Christian

Hi, Sharp,

Sharp said:
My problem was I put the *.jar files in the jdk/jre/ext/
and the java and class files in a desktop folder.

I made sure everything pointed in the right direction but still doesn't
work.
You want to give it a try?

Jup.

Now I could reproduce the error. Its the JoSQL-1.0.jar. If its in the
ext-directory, the execution will fail :-( The 3rd-party jar does not
make any problems. It also fails, when the JoSQL jar is in the current
directory and it is not "referenced" through the classpath but via the
java property java.ext.dirs.

So I think you found a bug in the package, concerning the reflection
mechanism used in it.


Greetings,

Christian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top