• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting started with JSP and DB2 Access  RSS feed

Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just getting started with JSP for creating dynamic web content. My experience previously been with ASP and ODBC, however, I am now working in an AIX environment running Apache and Tomcat. I'm trying to get the basics of connecting to DB2 through a JSP page, but am not having the best luck. Here's what I've done so far.
Created a Java class called db2test.class. This java class does a few things:
Load JDBC driver(db2 net driver).
Opens connection.
Creates a statement.
Executes a query and puts it in a return set.
Returns the RS.
I then have a JSP page that:
Imports the db2test class.
Does a useBean on the class.
Calls the executeQuery method in db2test class and places returned value in a Return Set variable.
It then does a while next() on the rs and prints the value to the screen.
Very simple and straight forward. Here are few questions associated to this:
1) Is this the correct method of communicating with a database?
2) Is this the correct integration of Java Classes and JSP?
3) Any pointers for developing better database applications in JSP?
4) What is this error:?
org.apache.jasper.JasperException: Unable to compile class for JSP/apache/tomcat/work/localhost_8080%2Fwarehouse/_0002fdb_00032test_0002ejspdb2test_jsp_0.java:14: Class db2test not found in import.
import db2test;
As you can see, I've not actually gotten the code to run. I have put the .class file in the directory where the .jsp is located. I assume this error means it is in the wrong place. How do I find out where to put it.
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are running tomcat, then the class file should be under tomcat/webapp/folder/WEB-INF/classes, and the .jsp web be in the same level as WEB-INF. that is why u class file can not be found.
As of database connection, pooling is better. As of design, I am not that experienced yet.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!