tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From java4din...@indya.com
Subject My code
Date Mon, 19 Mar 2001 07:49:06 GMT
My application works perfectly fine with the public static void main 
but not with Servlets in Tomcat


import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;


public class IDSTest2 extends HttpServlet{



     public void doGet(HttpServletRequest request,
                      HttpServletResponse res)
        throws IOException, ServletException
             {
PrintWriter out = new PrintWriter(res.getOutputStream());
res.setContentType("text/html");

out.println("<html>");
out.println("<head>");                
out.println("<title>TESTING </title>");                
out.println("</head>");                
String name,pass;                
                try {

                     Class.forName
("org.gjt.mm.mysql.Driver").newInstance(); 
					 
Connection C = DriverManager.getConnection
("jdbc:mysql://localhost:3306/test?user=nobody");
                  out.println("Connection Established");
Statement st = C.createStatement();
ResultSet rs = st.executeQuery("Select * from Login");

while (rs.next()) {
	
	name = rs.getString("name");
	pass = rs.getString("Password");
	out.println(name);
	out.println(pass);
	}
	st.close();

      
}
                catch (Exception E) {
                    System.err.println("Unable to load driver.");
                    E.printStackTrace();
                }

}

The Start of the Error is


Unable to load driver.
java.sql.SQLException: [TCX][MyODBC]Can't connect to MySQL server 
on 'localhost' (10061)
        at sun.jdbc.odbc.JdbcOdbc.createSQLException
(JdbcOdbc.java:6031)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
        at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2458)
        at sun.jdbc.odbc.JdbcOdbcConnection.initialize
(JdbcOdbcConnection.java:320)

Enjoy being an Indyan at http://www.indya.com

Mime
View raw message