Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RAQ4 tomcat database connection problem

Status
Not open for further replies.

pepperjones

Programmer
Jul 25, 2003
3
GB
I have recently implemented Tomcat 3.2.2 on a linux RAQ4 server with admin privilages. The test code below should connect me to an MicrosoftAccess database, it works on my local host which is windows by the way. (more explaination after code)

<%@ page import=&quot;javax.servlet.*,java.sql.*,java.util.*&quot; %>
<%

Connection con ;
Statement stmt;
ResultSet rs;

String dishes = null;
String course = &quot;Soups&quot;;

try {

Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;).newInstance();


con = DriverManager.getConnection(&quot;jdbc:eek:dbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=/home/sites/site27/web/Recipes.mdb&quot;);


stmt = con.createStatement();

stmt.executeQuery(&quot;tblRecipes&quot;);


while(stmt.getResultSet().next() )
{
dishes = stmt.getResultSet().getString(&quot;course&quot;);

%>
The dish is: <%= dishes %> <br>

<%
}

}
catch(SQLException e){ e.printStackTrace(); }

%>

I get the error Internal Servlet Error:

javax.servlet.ServletException: Unable to load class sun.jdbc.odbc.JdbcOdbcDriver

and also the error

Root cause:
java.lang.ClassNotFoundException: Unable to load class sun.jdbc.odbc.JdbcOdbcDriver

I have changed the file in /etc/profile.d/java.sh classpaths to point to all relevant .jar files including rt.jar(which contains the jdbc driver doesnt it??), this is located in /usr/jdk1.3.1/jre/lib/rt.jar).
I have tried using the newInstance() and tried it without, i have rebooted the server and restarted tomcat but nothing works. Help help HELP HELP!!!!



 
I tried your code on Tomcat 5, jdk1.4.2beta and its fine ... are you sure your environment variables are set up correctly (TOMCAT_HOME, CLASSPATH, JAVA_HOME etc) ?

By the way you don't need to point your CLASSPATH to the internal/standard jar files like rt.jar.

 
how do i change the environment vars(what is the file called) on a cobalt raq4 linux server, i have admin privliges, I think the environment vars r ok, i installed a pkg on the server so everything is done, all the dirs have been set up and normal jsp pages can compile, please HELP HELP, i dont know what is wrong this is driving me mad
 
>>> how do i change the environment vars(what is the file called)

Depends on how your server is set up, but in your user profile home dir, there should be a file called &quot;.profile&quot;, or in /etc/rc.local or /etc/init.d, there are a bunch of scripts which get run when linux starts. You need to add your line in one of these ....

export CLASSPATH=$CLASSPATH:/usr/local/someClassDir
 
done that still does not work, i think the interbase driver works but i can only create a database not create a table in it or query it, any help with that would help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top