I'm not sure if this is your problem but I'd use the code like this,
String url = "jdbc:oracle:thin@myhost:1521:otest";
/*Compared to mine
String url = "jdbc:oracle:thin:@patmos:1521:orcl";
*/
String user = "sa";
String password = "pass";
Then
con = DriverManager.getConnection( url, user, password );
Also have you made sure that the driver is loaded into your classpath?
-----Original Message-----
From: Spencer Tasker [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 12, 1999 12:45 PM
To: [EMAIL PROTECTED]
Subject: JDBC from Servlet (doPost)
<< File: dbtestapp.java >> << File: dbtestserv.java >> Hi,
I have written a sample simple servlet (with doPost method - since I would
want to pass a parameter back from a form in the real version of the
servlet) which is supposed to use JDBC to access an oracle database and pull
back a bit of data. Unfortunately, it fails to work, telling me that it
cannot find the JDBC driver, failing on the line
Class.forName("oracle.jdbc.driver.OracleDriver");
Full error messages follow�at end of message.
When I rewrite this simple servlet as an application it runs 100% OK.
I have attached the 2 servlet & application source files in case anyone is
interested, but I'm lost as to why I can't get hold of the database from the
servlet. This must be a common situation, but I haven't found it mentioned
anywhere.
For what its worth I'm running Apache Jserv.
Thanks in advance,
- Spencer
ERROR MESSAGES--------------------------------
Unable to load JDBC driverException: null <<< from my code
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:111)
at java.sql.DriverManager.getConnection(DriverManager.java:149)
at dbtestServlet.doPost(dbtestServlet.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:521)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.run(JServConnection.java:359)
at java.lang.Thread.run(Thread.java)
Unable to read derivation: No suitable driver <<< from my code
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html