Hello All !!!
I 'm in a rather strange position . I've a servlet that fetches data from a MySql DB .
If the database is without a password it works perfectly fine . Ironically if i assign
a user name and passwd to the DB the servlet doessn't seem to like it and throws up
the foll :
"SQLState: 08S01 Message: Communication link failure: Bad handshake Vendor: 1043 " on
the browser
java.sql.SQLException: Communication link failure: Bad handshake
at org.gjt.mm.mysql.MysqlIO.init(Compiled Code)
at org.gjt.mm.mysql.Connection.<init>(Connection.java:230)
at org.gjt.mm.mysql.Driver.connect(Driver.java:126)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:159)
at Shopper.<init>(Shopper.java:21)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Compiled Code)
at com.sun.web.core.ServletWrapper.loadServlet(ServletWrapper.java:90)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:109
)
at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140
)
at com.sun.web.core.Context.handleRequest(Context.java:375)
at com.sun.web.server.ConnectionHandler.run(Compiled Code)
Shopper: init
My servlet code is as follows :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Shopper extends HttpServlet
{
Connection con;
PreparedStatement stmt, stmt1;
ResultSet rs,rs1;
ResultSetMetaData rsmd;
int numcol;
public Shopper()
{
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost:3306/project?user=Donald&password=Donald";
// If no password assigned to DB
// String url="jdbc:mysql://localhost:3306/project";
con=DriverManager.getConnection(url);
stmt=con.prepareStatement("select * from productregister");
stmt1 = con.prepareStatement("select * from productregister where code=?");
}
catch(java.lang.Exception ex)
{
ex.printStackTrace();
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
..
...
}
Any help would be deeply appreciated
Regards
Donald
----------------------------------------------------------
God gimme patience er ....... but hurry up !!!!!!!!!!
----------------------------------------------------------