Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

JoSQL reposted

Thread view: 
Sharp Tool - 23 Oct 2005 02:49 GMT
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
Roedy Green - 23 Oct 2005 04:43 GMT
>Caused by: java.lang.ClassNotFoundException: classfiles.Person
my sympathies. This is my least favourite run time error.

See http://mindprod.com/jgloss/caq.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Christian - 23 Oct 2005 11:50 GMT
Hi Sharp,

Sharp Tool schrieb:
> Hi,
>
[quoted text clipped - 14 lines]
>   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
Sharp Tool - 23 Oct 2005 15:03 GMT
> Hi Sharp,
>
[quoted text clipped - 52 lines]
>
> 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
Christian - 23 Oct 2005 16:25 GMT
Hi, Sharp,

Sharp Tool schrieb:
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.