Hi,

I read your code on servletsource.com by downloading the zip file which has a HC.java file, for connecting to the databse using jdbc. I am trying the same but haven't succeded. I have also posted this question to the servletfourm 'june'  '99 section.

I am running Apache Web Server and Apache JServ on one machine (say M1) and the database (Oracle 7.2.3) is on another machine (say M2) . I have the jdbc thin driver installed on Machine M1 in the /usr/local/jdbc/lib/classes.zip. I have added this path to the jserv.properties file in wrapper.classpath.

The following code compiles without error but while running it give ClassNotFoundException as well as error 'No Suitable Driver". What could be the reason for this :

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.math.*;
import java.net.*;
import java.lang.*;

public class FourOOneK extends HttpServlet
{
    Connection con;
    public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
 

        ServletOutputStream sout = res.getOutputStream();
        res.setContentType("text/html");

        try {
            //DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
            Class.forName("oracle.jdbc.driver.OracleDriver");
        }

        catch(ClassNotFoundException e)
        {
        sout.println( "<br>Error Oracle Driver Not Found: " + e + '\t' );
        }

        try {
        con = DriverManager.getConnection("jdbc:oracle:thin:@xxxx:portno:yyyy", "usrname", "pwd");

    / / What should be there in place of xxxx and yyyy??

        //sout.println("<html>");
        //sout.println("<head><title>My Table List </title></head>");
        //sout.println("<body>");
        //sout.println("I am here");

        //DatabaseMetaData dmd = con.getMetaData();

        // sout.println ( "<br>You are connected to : " + dmd.getDatabaseProductName() );
        //sout.println ( "<br>The database version no. is : " + dmd.getDatabaseProductVersion() );
        //sout.println ( "<br>You are currently logged in as : " + dmd.getUserName () );
        //sout.println ( "</body></html>" ) ;
        }

        catch(SQLException e) {
            sout.println ("<br>Error Connection : " + e.getMessage() );
        }
 

    }
}

Kindly help me to solve this apparently simple but persisting issue. Any help is highly appreciated.

Thanks in advance

Gaurav

Reply via email to