Java- MySQL Connection (Create Table, Insert, Select)




This is a fast tutorial, intended for people who understand java, and the basics of SQL/MySQL who just want to see how to use my-sql-connector. How to create a …

Original source


20 responses to “Java- MySQL Connection (Create Table, Insert, Select)”

  1. The throws Exception will never throw anything as it is already caught and "handled" in the catch clause of your try. Of course you might eventually pass the error upwards, in which case it'd be used, but as for now, it is technically dead code.

  2. Great work!
    I have an issue when I run the code:

    WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

    Any help please?

  3. Hi Steven,

    Good video.

    What is the purpose of the code "Class.forname", i had this is my code but then I commented it out and yet I was able to establish connection to DB and was able to execute my queries and get results.

    I will keep it commented unless I find the reason for using it

  4. I get the following exception msg:

    "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."

    I am trying to connect to a testdb on my ubuntu vps and I'm sure that I wrote the url, username, password correctly. I'd be glad if you help, thanks.

Leave a Reply