Hi,

I am testing the following code that attempts to get a
DB connection, but I keep getting the following error:

database_test.DBConnector 
SQLException: No suitable driver
SQLState: 08001
VendorError: 0

The code snippet is below. I know the DB I am trying
to connect to exists and that the userid and password
is correct. I am not sure if I am giving the connect
string the correct location of my menagerie DB or not.
How can I figure out where it lives?

public class DBConnector
{
    //Class State
    private String dbuser,dbpasswd,dburl;

    public DBConnector()
    {
        dbuser="sspiegler";
        dbpasswd="cuatro";
        dburl=
           
"jdbc:mysql://localhost:3306/menagerie?user="+dbuser+"&password="+dbpasswd;
    }
    public DBConnector(String aDburl,String
aDbuser,String aDbpasswd)
    {
        this.dbuser=aDbuser;
        this.dbpasswd=aDbpasswd;
        this.dburl=aDburl;
    }

    public Connection getConnection () throws
SQLException
    {
        ResultSet rs=null;
        Connection conn=null;
        try
        {
            conn = DriverManager.getConnection(dburl);
            
            if (rs != null)
            {
                // here you would do something with
the ResultSet
            }
        }
        finally
        {
            if (rs != null)
            {
                
            }
        }
        return conn;
    }
       /**
    *  *** for testing purposes only ***
    */
    public static void main(String[] args)
    {
        Connection aConn = null;
        DBConnector dbc = new DBConnector();
        try
        {
            aConn = dbc.getConnection();
        }
        catch(SQLException sqle)
        {
            System.out.println("SQLException: " +
sqle.getMessage());
            System.out.println("SQLState: " +
sqle.getSQLState());
            System.out.println("VendorError: " +
sqle.getErrorCode());
        }
    }
}


=====
We don't see things as they are, we see things as we are.
    --Anais Nin


                
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to