All things are lawful, but not all things are profitable.
MySQL wrote:Access denied for user ''@'localhost' (using password: NO)
Paul Clapham wrote:Hi Wensley, welcome to the Ranch!
You posted some code:
which gets a connection, using user ID "root" and an associated password. But on the other hand your error message:
MySQL wrote:Access denied for user ''@'localhost' (using password: NO)
which says that somebody tried to get a connection using no user ID and no password.
So it seems that the code you posted isn't the code which is causing the exception.
And no, I didn't watch the tutorial. Video is such a horribly linear format, whereas if it was a text-based tutorial I could just search for the relevant section.
EDIT: I see you edited your post to link to a text-based tutorial as well as the video tutorial. That's a useful change but it would also be useful in future if you could insert a comment (like this one) when you edit one of your posts.
Wensley Brands wrote:Anyway could it be that MySQL settings are not correct?
Paul Clapham wrote:
Wensley Brands wrote:Anyway could it be that MySQL settings are not correct?
It certainly could (for some definition of "not correct"). It's clear that your MySQL installation is set up with user IDs and passwords. I would expect that you did that at some point, or was somebody else involved in the setup? Anyway to use your MySQL you're going to have to provide a user ID and password which matches a user ID which it knows about.
Wensley Brands wrote:Would it help to screenshot a certain part of MySQL settings ?
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:
Wensley Brands wrote:Would it help to screenshot a certain part of MySQL settings ?
It would help a a lot more if you'd stop using media-intensive examples. Just copy-and-paste the text. No videos, no screenshots. No singing fairies and no dancing flowers. Not unless we ask specifically.
It's just a lot easier for us to read plain text (with code tags) than have to deal with a circus.
Also, Class.forName is long obsolete. You can completely delete that line.
For specifics on how to form MySQL JDBC URLS: https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-jdbc-url-format.html
It's a pretty "busy" page itself, but it's quite detailed.
Wensley Brands wrote:
That's exactly what i wanted to do when i first started the post but i am a new user i dont have any Pie's that allows me to post a lot of code lines, sorry for all the links!
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Wensley Brands wrote:No i installed it myself on my desktop pc. I will reinstall it to see if it fixes this issue. Yes i did use an ID and Password which is shown in the code to access the MySQL DB user: root pass: r00t1
Tim Holloway wrote:Did we start limiting how much text can be posted? Nobody told me!
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
Paul Clapham wrote:
Wensley Brands wrote:No i installed it myself on my desktop pc. I will reinstall it to see if it fixes this issue. Yes i did use an ID and Password which is shown in the code to access the MySQL DB user: root pass: r00t1
It may be that the tutorial told you to use that ID and password in the code. However if you didn't actually go into MySQL as admin and set that ID up with that password, then it isn't going to work.
Reinstalling MySQL is not going to help. It's a relatively simple matter to manage users and their passwords in MySQL so that's the direction you should go in.
Wensley Brands wrote:Also when i test the connection on MySQL it says succes! This just makes 0 sense duo to the fact it connects smoothly in tutorial 34 :(
Wensley Brands wrote:The complete code is now included in this post, hope it fits your sscce standard.
All things are lawful, but not all things are profitable.
Paul Clapham wrote:
Wensley Brands wrote:Also when i test the connection on MySQL it says succes! This just makes 0 sense duo to the fact it connects smoothly in tutorial 34 :(
If "in tutorial 34" refers to some other person running code on some other computer, then that means nothing. However if it refers to some code running on your computer, then it's worth looking into. Do you have two different code examples which use the same user ID and password but, which when run on your computer, have different results with respect to being allowed to connect?
It's possible you didn't notice that the MySQL permissions system allows you to specify which hosts a user may connect from, and thus haven't set up your user ID to be allowed to connect from localhost.
Exception in thread "main" java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
Paul Clapham wrote:It still remains to be answered why the stack trace you posted documents a connection attempt with no user ID and password:
Exception in thread "main" java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
It also remains to be answered why the stack trace doesn't mention any of your code in it. In other words, what code tried to make that connection and why? I don't see any connection between that code (which is using a TimezoneDump class from the JDBC driver) and your JavaLesson36 class.
All things are lawful, but not all things are profitable.
Wensley Brands wrote:In advanced system settings -> enviromental variables... i created a new user variable to the jdk 11.3
And because you said something about TimeZoneDump class i synced my time zone in MySQL commandline with: SET GLOBAL time_zone = 'SYSTEM';
It then gave me an error saying it can't recognize west europe time zone it represents mulitply country's, so i did SET GLOBAL time_zone = '+2:00'; <- which is weird i did this before i created this post and it did not work.
I did all of the above and now it's working 100 %.
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|