aspose file tools*
The moose likes Tomcat and the fly likes Using CachedRowSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Using CachedRowSet" Watch "Using CachedRowSet" New topic
Author

Using CachedRowSet

Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Alright, so I'm working on showing all the cds available within a genre. It starts with a user clicking on a link to a specific genre with the genre id included as a parameter in the url. The controller will receive this and pass it on to the model to get all cds that are in that genre. I'm returning the resultset from the model. My only problem is, how do I get to use the cachedrowset?

I'm importing using:
import sun.jdbc.rowset.*;

and this is how I'm using it:
CachedRowSet crs = new CachedRowSet();
ResultSet result = cds.getCDsByGenre(connection, genre);

crs.populate(result);
connection.close();

However when I compile I get an error saying that package sun.jdbc.rowset.* doesn't exist. What am I doing wrong?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This is not a servlet question, moving to the JDBC forum.

Dave
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Jenn Person:

import sun.jdbc.rowset.*;



Jenn,

You are importing sun.jdbc.rowset.*; for this you need rowset.jar in your class path as sun.jdbc.rowset.* is the part of rowset.jar not JDK release.
place the rowset jar in your class path it should solve your problem.

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

one thing I want to add that you can use CachedRowSet if using JDK 1.5

You could import javax.sql.rowset.CachedRowSet


Shailesh
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
alright so I've downloaded rowset.jar and placed it in my classpath. Within my controller servlet I still have import sun.jdbc.rowset.*; however I still get there error stating package doesn't exist. Do I have to change the import path? like import rowset.*;?? Please help!!
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
I'm still having problems getting my servlet to compile with the cachedrowset. A friend of mine told me I should include a manifest.mf file. Is that necessary? Otherwise, I think I've done everything. Anyone who can help would be appreciated!!
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1134

Dave,
You said...

This is not a servlet question, moving to the JDBC forum

In my opinion, this is a compilation problem, so what forum is appropriate for questions regarding compilation errors?

Jenn,
Shailesh may have given you incorrect information. Have you verified that the class[es] you require are actually in the "rowset.jar" file?
Also, are you compiling from the command line, or via some IDE (or similar)? If you're using an IDE, it may be ignoring your CLASSPATH (environment variable) setting.

Or, as Shailesh suggests, upgrading to JDK 5.0 should solve your problem.

Good Luck,
Avi.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Avi Abrami:

Shailesh may have given you incorrect information


I may !!! give incorrect information but not this time I think so
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Jenn,

first verify that rowset.jar is in your compilation class path and second verify that sun.jdbc.rowset.CachedRowSet class exist in your rowset.jar

because sun has released more 2 or 3 version of rowset.jar so extract your jar and verify that class file.

and if class exist it should be in your classpath

thanks
[ March 31, 2005: Message edited by: Shailesh Chandra ]
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1134

Shailesh,

sun has released more 2 or 3 version of rowset.jar

I stand corrected. Not incorrect information, but incomplete information.

extract your jar and verify that class file

Isn't that [almost] what I said? By the way, you can verify that a class is in a JAR without extracting the class. Refer to the javadocs for the "jar" tool to find out how.

Good Luck,
Avi.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Avi Abrami:
Isn't that [almost] what I said?


Not almost exactly same content in different words.


By the way, you can verify that a class is in a JAR without extracting the class.


My Idea is to give direction in easiest possible way.There are numbers of way to do one thing.

thanks
Shailesh
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
ok so I checked the rowset.jar file and it does contain the cachedrowset. However the problem is still the same. I get a compilation error now saying the package sun.jdbc.rowset.*; does not exist.

Part of my classpath is c:/jakarta-tomcat/webapps/jTunes/WEB-INF/classes
I've placed the rowset.jar file in my classes directory as instructed and use include sun.jdbc.rowset.*; in my servlets, but still get the same error.

I don't know what I'm doing wrong, and anyone who can help is greatly appreciated!!
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

create a folder lib inside WEB-INF folder and place your jar file there

Shailesh
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Originally posted by Shailesh Chandra:
create a folder lib inside WEB-INF folder and place your jar file there

Shailesh


Ok so just create a folder named lib under the WEB-INF directory and toss the rowset.jar file in... sounds easy enough.... but do I have to change my classpath at all?? Right now it's pointing to the classes folder within my WEB-INF??

part of my current classpath:
c:/jakarta-tomcat/webapps/jTunes/WEB-INF/classes
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Jar files are placed in web-inf/lib folder, and classes of jar file are picked during runtime of application.

I am assuming that you are using same class path for compilation,hence it should work.
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Originally posted by Shailesh Chandra:
Jar files are placed in web-inf/lib folder, and classes of jar file are picked during runtime of application.

I am assuming that you are using same class path for compilation,hence it should work.


ok I'll give it a shot, and let you know. Thanks!!
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Alright I've added a lib directory to my WEB-INF folder, however when I try to compile it still says 'package sun.jdbc.rowset does not exist'. Should my import statement still be 'import sun.jdbc.rowset.*;' or should the path be changed? I don't understand what I'm doing wrong??
Jason Kwok
Ranch Hand

Joined: Mar 31, 2005
Posts: 126
You should try installing JDK 5.0. Instead of using the sun.jdbc.rowset package, you can use import javax.sql.rowset.* which comes with JDK. Hopefully this solves your problem.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Jenn,

Still I have doubt that rowset.jar is in your compilation classpath.
either update to jdk1.5 this will solve problem or verify if jar file is in your compilation path.

I have seen two rowset.jar so far.

In first one which was early release,CachedRowSet was place in sun.jdbc.rowset package. But in next release it was replaced to javax.sql.rowset package.

even in jdk 1.5 it is in javax.sql.rowset package
ss_java
Greenhorn

Joined: Jan 28, 2005
Posts: 6
give this statement also..

import javax.sql.rowset.*

let me know if it is solved
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Ok I download JDK 5.0 and my code compiles when I import the new library. HOwever now when I start Tomcat and try to view the results tomcat cannot find the servlet. I was using j2sdk1.4.2_02 which is where my JAVA_HOME variable was pointing to. Do I need to change that to JDK 5.0?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

How are you running Tomcat?
From the command line?
As a windows service?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
As a windows service. After I installed tomcat, start and stop icons were added and I use those to activate it. So should I change my JAVA_HOME variable?

My current autoexec file:
SET Path=C:\WINDOWS;C:\WINDOWS\COMMAND;
SET CATALINA_HOME=c:\jakarta-tomcat-4.0.1
SET JAVA_HOME=c:\j2sdk1.4.2_02\bin
SET CLASSPATH=c:\jakarta-tomcat-4.0.1\common\lib\servlet.jar;c:\jakarta-tomcat-4.0.1\webapps\bookStore\WEB-INF\classes

should it be changed to where JDK 5.0 was installed?? For example:
C:\Program Files\Java\jdk1.5.0_02\bin
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Jenn,

Good to know that finally your code compiled.


SET JAVA_HOME=c:\j2sdk1.4.2_02\bin


I dont think that JAVA_HOME includes \bin

should it be changed to where JDK 5.0 was installed??


you should change to refer liabrary of jdk1.5
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Alright I changed my autoexec but I get an exception saying a servlet instance could not be found and the root cause was with java.lang

This is my current autoexec file:
SET Path=C:\WINDOWS;C:\WINDOWS\COMMAND;
SET CATALINA_HOME=c:\jakarta-tomcat-4.0.1
SET JAVA_HOME=c:\Progra~1\Java\jdk1.5.0_02\bin
SET CLASSPATH=c:\jakarta-tomcat-4.0.1\common\lib\servlet.jar;c:\jakarta-tomcat-4.0.1\webapps\jTunes\WEB-INF\classes

Maybe I'm really inexperienced, but it seems like java is just one headache after another!!!

Thanks to everyone who've taken the time to help me, keep the advice coming please!!
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

can you put complete exception message !!

Now your problem is tomcat specific !! I would recommend to start a new thread in Apache/Tomcat forum, so that other rancher can also help you


but it seems like java is just one headache after another!!!


more headache more expert
[ April 03, 2005: Message edited by: Shailesh Chandra ]
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Jenn, JAVA_HOME like CATALINA_HOME is an environment variable that points to the base(top level) directory of the JDK and TOMCAT installations. The PATH environment variable points to the executables of the operating system i.e. dos commands, java.exe, javac.exe. Therefore:
I dont think that JAVA_HOME includes \bin


So your autoexec.bat should look something like this:


Notice the last entry(s) in the PATH variable. I includeded the the Catalina entry if for example, you were starting/stopping from the command line.

The current setting for the JAVA_HOME be the cause of why you are getting
[QOUTE]
the root cause was with java.lang
[/QOUTE]
exception from TOMCAT, although it would help if you posted the entire stack trace. The reason being is that TOMCAT may not find the base packages, TOMCAT, I believe uses the JAVA_HOME environment variable to locate those packages. So if the JAVA_HOME environment variable is pointing to the bin directory, you may have a problem.

So correct the autoexec.bat, reboot your PC, and give it a try. Let us know how it goes.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Correct syntax for PATH environment variables on windows should be



Ignore the "$", my mind, just jumped to linux/unix syntax and back to dos.
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Alright, I'll try that all out and let you know the results this afternoon, hopefully this will be the end to my nightmare!! Thanks again!!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

When you install Tomcat as a Windows Service, it doesn't use environment variables to find the JVM. Those values are stored in the registry.

If you checked the "Start Menu Items" node during installation, you can change the JVM pointer by going to "Start -> All Programs -> Apache Tomcat -> Configure Tomcat -> Then click on the Java Tab.
From there, you will be able to change the pointers.
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Well I'm using Windows 98, and I just downloaded Tomcat and j2sdk from a website and installed them. After that, I had to manually edit my autoexec.bat file to include JAVA_HOME, CATALINA_HOME, and CLASSPATH.
Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
Hey guys, I'm still having problems running servlets now. Here's the complete exception message:

Apache Tomcat/4.0.1 - HTTP Status 500 - Internal Server Error

--------------------------------------------------------------------------------

type Exception report

message Internal Server Error

description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot allocate servlet instance for path /testarea/servlet/hope
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:415)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Unknown Source)


root cause

java.lang.UnsupportedClassVersionError: testing/hope (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1534)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:852)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1156)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:801)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:396)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Unknown Source)
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Somewhere along the lines this became a Tomcat question, so I'm moving this there.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using CachedRowSet