1

I'm assuming I need to use Connector\J and JDBC to achieve this, but I can't seem to 'install' Connector\J using the CLASSPATH thing. How do I do that ? I use the IntelliJ IDE if thats relevant.

I'm looking for a way to talk to a mysql database and execute and print out a few basic queries but I'm not getting anywhere because I can't even talk to the database.

Any help is appreciated.

4 Answers 4

7

You might follow an example such as this one:

http://www.kitebird.com/articles/jdbc.html

But, you might want to consider using Hibernate unless you're doing only a couple basic queries.

Sign up to request clarification or add additional context in comments.

Comments

4

See Using MySQL with Java -- the first link from Google.

2 Comments

Rich B is eliminating all lmgtfy posts. I have no problem with that, but I'd like there to be at least some content (not that there was any to start with, but people did upvote some of those answers).
Isn't it down to other users to downvote such answers rather than have RichB edit the answer into nonsense?
3

I like this tutorial because it's very detailed and thorough. Pretty much every step from downloading and installing MySQL and Connector/J to writing and running queries is covered.

Comments

1

Which version of IntelliJ?

You need to add the MySQL Connector-J JAR to your project dependencies.

Open your IntelliJ settings (the "wrench" in the top menu bar), go to "Libraries", click on "Attach Classes", and add the MySQL Connector-J JAR that you downloaded above. That puts it in your CLASSPATH.

If you still have problems, it means you don't have the driver class name right. It should be com.mysql.jdbc.Driver.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.