Hey, I'm looking for decent MySQL tutorials for connecting a Database in Java. I'm using Java 8 so preferably would like tutorials that correspond with newest code.
Jump to Post
The definitive Oracle tutorials are kept up to date, and include MySQL...
AFAIK there were no significant SQL-related changes in JDK 8.
Code is always the same because Java take care of backward compatibility.
Here you have tutorial about connection to database.
They explain every line of code what is made for.
Read that and I think you will not have any problems in future.
Kind regards, Mike.
my advice: learn to write your persistency code in such a way that it's not db dependent. it's much easier to work if on changing a db, all you need to do is change one single property, and not your actual code.
^ like he said.
For learning, unles you are already a MySQL admin fiend, I can recommend using the JavaDB that came with your JDK, and NetBeans which has support for JavaDB burned in to its "services" tab. Setting up a database server isn't trivial unless you already know how how to do it. Using NetBeans/JavaDB will enable you to concentrate on your Java. Later you can change the
connect statement to work with MySQL or whatever - the rest of the Java SQL support is database-independent.
Just saw milil's post -
Beware that tutorial if you want current info. It starts with
classForName, which became obsolete in 2006 (if not earlier).
Telling you to use classForName is a dead give-away for a tutorial that's not been updated for years and years.
I figured I would use the Oracle tutorials as that would be the most official, and probably up to date tutorial.
I already have a MySQL server running a database and tables set up. I appreciate the advice however.
Do I still need to download the JDBC Connector in order to connect to a MySQL database?