Java JDBC Tutorial – Part 1: Connect to MySQL database with Java




5 FREE JAVA VIDEO COURSES – CLICK HERE – https://goo.gl/7i95F8 — View more videos on my “Java JDBC Tutorial” Playlist: http://goo.gl/crT4nS …

Original source


38 responses to “Java JDBC Tutorial – Part 1: Connect to MySQL database with Java”

  1. Hey, nice tut but.. I have a prob.

    I made a table with mysql workbench and saved it at C://SQL/test.mwb
    Do I use this instead of jdbc:mysql://localhost:3306/Demo ?!
    And where do I find the username and password. I never set up a username or password in the mysql ?

  2. Tue Jul 25 01:58:17 IST 2017 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.
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'demo.employessinfo' doesn't exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.Util.getInstance(Util.java:408)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2490)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2448)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1381)
    at jdbcdemo.Driver.main(Driver.java:18)

    i got this every time…

  3. Sun May 28 20:44:54 IST 2017 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.

  4. HELP PLEASE

    Mon May 22 15:58:17 EEST 2017 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.
    java.sql.SQLException: Column 'GIAMOURIDIS' not found.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
    at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1077)
    at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5174)
    at databases.Databses.main(Databses.java:17)

  5. it's 5 the morning I am working on my Semester project on database adapter, I tried everything that my database teacher show us o the presentation, nothing works, did that for at least 2 hours. Found this video start working in 9 minutes. You man deserve a cookie. Harvard or Yele need to hire you as a teacher I swear. God bless you and take care.

  6. Connecting to database…
    Mon May 15 22:34:29 IST 2017 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.
    Creating statement…
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'emp.employees' doesn't exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.Util.getInstance(Util.java:408)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2444)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1381)
    at FirstExample.main(FirstExample.java:29)
    Goodbye!
    solve this error boss

  7. Thanks for the tutorial; however, if the web app has a lot of traffic, this method of database implementation will make the app deadly slow. Using connection pool is better and the standard way to implement a java database connection in the Java world. Thanks though !

Leave a Reply