JDBC, MySQL connection

B

bb

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!
 
S

sankar_battula

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...
 
R

Roedy Green

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);
 
T

TechBookReport

bb said:
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
 
J

jonck

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top