• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting error...please help

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
// imported all the servlet & java packages reqd.
public class AAA extends HttpServlet {
String JDBC_URL;
public void init() throws ServletException {
String driver;
driver = getServletConfig().getInitParameter(�driver�);
JDBC_URL = getServletConfig().getInitParameter(�jdbc_url�);
Note  System.out.println(driver); //to send to server console
System.out.println(JDBC_URL);
if( driver == null | | JDBC_URL == null) {
This one -> throw new UnavailableException(�Driver not specified�);
}
try {
Class.forName(driver);
}catch(ClassNotFoundException abc){
throw new UnavailableException(�The�+driver+�not found in classpath�);
}
}
The balance service method --------
And in the web.xml i specified other than the servlet name the init param like this

driver
COM.cloudscape.core.JDBCDriver
and similarly for the JDBC_URL
Now i started the server I am using TOMCAT 3.2.1
Now when i start the server (in the web.xml i had mentioned load at start up) on the start up console i get the message COM.cloudscape.core.JDBSDriver and what ever specifeid for JDBC_URL
That means the initilization has taken place and the server has read the driver from web.xml
But now when i call the servlet on the browser an Unavaialble Exception mentioned by this one is thrown indicating that �Driver not Specified�. How come the driver object is null wheen it is printing on the console. Than i tried writing first String driver = null; this also didnot solve the problem. What i am not able to understand that if the getInitParameter method has worked as it has as seen by console out put how come than in the next line the same object is null.
Than again to check my programe i mentioned the driver in the source itself like
String driver = �Com.cloudscape.core.JDBCDriver�;
Could you comment that where could be the problem. I presume server is ok as it has initialized the string driver. And if i cannot use the web.xml than it is a problem when i need to mention context-param if i need to use more than one servlet in a web application and common init params.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

�Com.cloudscape.core.JDBCDriver�
Did you really use an upper case C in Com?
It is certainly not going be able to load a class with an incorrect package name.
Bill
 
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic