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