List:General Discussion« Previous MessageNext Message »
From:Gobi Date:November 24 2005 2:22am
Subject:Re: Cannot get database connection
View as plain text  
Hassan Schroeder wrote:

>Gobi wrote:
>
>  
>
>>MySQL 5.0.15 and Tomcat 5.5.12.  However, I cannot seem to get a
>>connection object from my servlet and for the life of me, I can't figure
>>out why.  Here is what I have done:
>>    
>>
>
>  
>
>>and I created the following servlet, TestSQL:
>>    
>>
>
>It's possible the two items below are transcription errors --
>
>  
>
>>   private Connection conn = null;
>>    
>>
>
>  
>
>>   try {
>>     if (conn == null) {
>>         Class.forName("com.mysql.jdbc.Driver").newInstance();
>>         connW =
>>    
>>
>
>? "conn" != "connW" :-)
>
>  
>
>>DriverManager.getConnection("jdbc:mysql://localhost/hostname", <id>,
>>    
>>
>
>Shouldn't the "hostname" above be "databasename"?
>
>However, correcting those two items, your code works fine on my own
>(slightly backlevel: TC 5.5.9 + MySQL 4.1.13+Connector/J 3.1.6) dev
>system.
>

Thanks.  Actually, I figured it out last night.  It was the hostname 
when it should have been the database name.
Thread
Cannot get database connectionGobi23 Nov
  • Re: Cannot get database connectionXiaobo Chen23 Nov
    • Re: Cannot get database connectionGobi23 Nov
      • Re: Cannot get database connectionXiaobo Chen23 Nov
        • Re: Cannot get database connectionGobi23 Nov
Re: Cannot get database connectionGobi24 Nov