JSP-MySQLconnection problem

Hi All

I am trying to connect from JSP page to MySQL Server, I use the following method to get connection , but it returns null.

private Connection getConnection()

{

Connection conn =null;

try

{

Class.forName("com.mysql.jdbc.Driver");

String url ="jdbc:mysql://localhost/acssDB";

String userName ="root";

String password ="pass";

conn = DriverManager.getConnection(url,userName,password);

}

catch(Exception e)

{

e.printStackTrace();

}

return conn;

}

Notes :

- When I call this method from java application, it run sucessfully.

- I use this connector mysql-connector-java-5.0.6-bin

[1138 byte] By [mansoorxpa] at [2007-11-27 7:57:05]
# 1

If it is null, then I guess an exception is occurring.

Check your logs/console for error messages.

At a guess, you don't have the database driver available to your web application. Try putting the file mysql-connector-java-5.0.6-bin.jar in the WEB-INF/lib directory.

If you are using Tomcat, I would recommend you put it into the [TOMCAT]/common/lib directory so you can also use it with Tomcat's connection pooling functionality.

If thats not it, post the error message/stack trace you get (the one you are printing out from your exception block) and we can go from there.

evnafetsa at 2007-7-12 19:38:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanksssssssssssss very much, it is runing
mansoorxpa at 2007-7-12 19:38:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...