JDBC, MySQL connection

Discussion in 'Java' started by bb, Oct 26, 2005.

  1. bb

    bb Guest

    Excuse me if I'm in the wrong users group for this question, but this
    forum is the best around so I'm giving it a shot. I have a connection
    statement to make a connection with a MySQL 3.1 database via JDBC that
    follows:

    con =
    DriverManager.getConnection("jdbc:mysql://localhost/billblac_?user=billblac_bill&password=wgb");

    The database name is billblac_ .
    There is an existing connection named billblac_bill, host = localhost,
    port = 3306, username = root, password = wgb1454. This connection
    connects to the database correctly.

    The error message I get when I try to connect via Java and the above
    statement is:
    java.sql.SQLException: Invalid authorization specification: Access
    denied for user 'billblac_bill'@'localhost' <using password: YES>

    I know there is a discrepancy between the Java connection string
    statement and the existing connection named billblac_bill, but I can't
    seem to get the exact settings correct.

    Any help would be GREATLY appreciated!
     
    bb, Oct 26, 2005
    #1
    1. Advertising

  2. bb

    Guest

    Hi!
    One thing you have to check is ,check the username and password of the
    database from which you want to access the data.
    put the same uname and pwd in the url of the connection statement.
    or it will be easy ,if you use connection pooling .....if know it....

    sivasankar.
    regards...
     
    , Oct 26, 2005
    #2
    1. Advertising

  3. bb

    Roedy Green Guest

    On 25 Oct 2005 19:12:37 -0700, "bb" <> wrote,
    quoted or indirectly quoted someone who said :

    >Any help would be GREATLY appreciated!


    Usually database will come with some sample code you can run with a
    toy database.
    What does the DriverManager.getConnection
    for that look like.

    1. Usually there is some sort of utility for getting database
    information without writing code.. See if you can get it to show you
    any of the strings you fed it in the test DriverManager.getConnection.
    Note how they are warped/mapped.

    2. Call me superstitious. Don't use _ or space or any punctuation at
    all in names, especially lead/trail ones.

    3. make sure you have a localhost entry in your hosts file.
    See http://mindprod.com/jgloss/hosts.html

    4. google for DriverManager.getConnection MySQL and see if you can
    fine examples of ssuccessful connection strings. That may give you a
    hint.
    For example, doing that, I found this peculiar looking thing:
    //MYSQL4.1
    conn = java.sql.DriverManager.getConnection(
    "jdbc:mysql://localhost:3333/test");
    test("MySQL4", conn);
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Oct 26, 2005
    #3
  4. bb wrote:
    > Excuse me if I'm in the wrong users group for this question, but this
    > forum is the best around so I'm giving it a shot. I have a connection
    > statement to make a connection with a MySQL 3.1 database via JDBC that
    > follows:
    >
    > con =
    > DriverManager.getConnection("jdbc:mysql://localhost/billblac_?user=billblac_bill&password=wgb");
    >
    > The database name is billblac_ .
    > There is an existing connection named billblac_bill, host = localhost,
    > port = 3306, username = root, password = wgb1454. This connection
    > connects to the database correctly.
    >
    > The error message I get when I try to connect via Java and the above
    > statement is:
    > java.sql.SQLException: Invalid authorization specification: Access
    > denied for user 'billblac_bill'@'localhost' <using password: YES>
    >
    > I know there is a discrepancy between the Java connection string
    > statement and the existing connection named billblac_bill, but I can't
    > seem to get the exact settings correct.
    >
    > Any help would be GREATLY appreciated!
    >


    Have you tried breaking out the username and password as separate
    arguments? Take a look at the MySQL example in the Java Developers
    Almanac (http://javaalmanac.com/egs/java.sql/ConnectMySql.html).

    Pan
    --
    TechBookReport Java book reviews:
    http://www.techbookreport.com/JavaIndex.html
     
    TechBookReport, Oct 26, 2005
    #4
  5. bb

    jonck Guest

    > con =
    > DriverManager.getConnection("jdbc:mysql://localhost/billblac_?user=billblac _bill&password=wgb");


    Here you are using password=wgb

    > The database name is billblac_ .
    > There is an existing connection named billblac_bill, host = localhost,
    > port = 3306, username = root, password = wgb1454.


    And here you say the password is wgb1454. Naturally MySQL is going to
    give you a security error, you are giving the wrong password in your
    connection string.

    Kind regards, Jonck
     
    jonck, Oct 26, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith Wansbrough

    Re: jdbc help:sun.jdbc.odbc.JdbcOdbcDriver

    Keith Wansbrough, Aug 16, 2004, in forum: Java
    Replies:
    0
    Views:
    803
    Keith Wansbrough
    Aug 16, 2004
  2. Betty
    Replies:
    1
    Views:
    9,933
    Juha Laiho
    May 21, 2005
  3. Marcelo
    Replies:
    15
    Views:
    7,009
    Alun Harford
    Nov 23, 2005
  4. bruce
    Replies:
    19
    Views:
    1,241
    Tom Anderson
    Sep 24, 2010
  5. bruce

    JDBC connection to mysql

    bruce, Oct 21, 2010, in forum: Java
    Replies:
    3
    Views:
    426
    Roedy Green
    Oct 26, 2010
Loading...

Share This Page