tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Wingfield <jon.wingfi...@mkodo.com>
Subject Re: Suitable Driver Error
Date Fri, 22 Aug 2003 08:51:38 GMT
Your url is wrong. Should be:

url="jdbc:mysql://localhost:3306/gmds";

The 3306 is the default port mysql accepts connections on. If you've 
changed it, change your url string.

HTH,

Jon

Luong Phan wrote:
> Hi all,
>  
> In my web application, I use mysql supported by Redhat Linux 7.3 to store database, jakarta-tomcat-3.2.4,
mysql-connector-java-3.0.6-stable-bin.jar, and JSP.
>  
> Every time, I run the program:
>  
> import java.io.IOException;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
> 
> public class Data {
>  private Connection connection; 
>  private Statement statement; 
>  
>  
>  public Data() throws ClassNotFoundException,SQLException{
>      
>   String DBDriver=null;
>   String url=null;
>   String username=null;
>   String password=null;
>   
>         password="myPassword";
>         username="myUserName";
>         url="dbc:mysql://localhost/gmds";
>         DBDriver="com.mysql.jdbc.Driver";
> 
>     try{  
>          Class.forName(DBDriver);
>          connection=DriverManager.getConnection(url,username,password);
>          statement=connection.createStatement();
>        }catch(ClassNotFoundException e){
>                      System.err.println("Failed to load JDBC/ODBC driver.");
>                      e.printStackTrace();
>       }catch(SQLException e){
>                      System.err.println("Unable to connect");
>                      e.printStackTrace();
>       }
>     }
> ...
> I get the error:
> Unable to connect
> java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager.java
  532)
> ...
>  
> What is suitable driver for my application? Please give me some words of advice!
>  
> Thanks a lot.
>  
> LuongPhan
> 
> 
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.




Mime
View raw message