1)putting a lightly loaded "engine light on" text message is neither helpful 
nor delivers any useful information to those of us trying to determine your 
error 
always include the message from the exception object e.g.
out.println ("Cannot connect to database server message="+e.getMessage());

2)
netstat -a | grep 3306
if you dont see tcp connection displayed on your output then mysql daemon is 
down..restart it

3)never put username and password on emails ..this is not a secure way to do 
business 
btw try implementing the same username to get into mysql 
$MYSQL_HOME/bin/mysql.exe --host=localhost --user=whatever_user 
--password=whatever_password --host=localhost

Martin Gainty 
______________________________________________ 
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und 
Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> Date: Mon, 21 Feb 2011 07:55:05 -0600
> Subject: connecting jsp with mysql
> From: anup.niro...@gmail.com
> To: users@tomcat.apache.org
> 
> Hi,
> 
> I am having difficulty in connecting jsp and mysql using Tomcat 7.0 .
> I downloaded jdbc driver "mysql-connector-java-5.1.15-bin.jar" and placed it
> in two locations:
> 
>    - CATALINE_HOME\lib
>    - C:\Program Files\Apache Software Foundation\Tomcat
>    7.0\webapps\lsc\WEB-INF\lib
> 
> I tried to connect using the following code but it always says:"Cannot
> connect to database server".
>  Do i need to make any configurations apart from this ?
> I tried to connect with the following code:
>   <%@page language="java" import="java.sql.*"%>
>         <%
>   Connection conn = null;
> 
>           try
>            {
>                String userName = "root";
>                String password = "nbuser";
>                String url = "jdbc:mysql://localhost:3306/test";
>                Class.forName ("com.mysql.jdbc.Driver").newInstance ();
>                conn = DriverManager.getConnection (url, userName, password);
>                out.println ("Database connection established");
>            }
>            catch (Exception e)
>            {
>                out.println ("Cannot connect to database server");
>            }
>            finally
>            {
>                if (conn != null)
>                {
>                    try
>                    {
>                        conn.close ();
>                        out.println ("Database connection terminated");
>                    }
>                    catch (Exception e) { /* ignore close errors */ }
>                }
>            }
> %>
                                          

Reply via email to