12. Networking
14. Unit testing

13. exercise: JDBC

  1. Review presentation JDBC
  2. If necessary:
    1. Run sudo leafpad /etc/apt/sources.list and uncomment lines staring with # deb... (delete #)
    2. Run sudo apt-get update to refresh info about repositories
  3. Run sudo apt-get install mysql-server command to install MySQL server
    1. Set password abcd1234 for MySQL's root user
  4. Run sudo apt-get install mysql-workbench to install MySQL workbench
  5. In MySQL execute .../src/main/java/org/activity13/database.sql SQL script
  6. Investigate org.activity13 package
  7. Implement classes Database and Teacher to pass unit tests

MySQL logging

To enable detailed logging on MySQL server:

  1. Open configuration file:

    sudo leafpad /etc/mysql/mysql.conf.d/mysqld.cnf
  2. Change two lines to following (i.e. remove from beginning of line):

    general_log_file        = /var/log/mysql/mysql.log
    general_log             = 1
  3. Restart mysql server:

    sudo systemctl restart mysql
  4. To watch log in real time, run command:

    sudo tail -f /var/log/mysql/mysql.log

Extra exercise

  1. Investigate package org.extra06.
  2. Implement persistence for Invoice and Item classes using JPA
    to pass unit tests.
  3. To view and manage H2 database from browser, run command bash from ...extra06 folder
Note that this (configuration of) H2 database supports only one connection. To run unit tests, connection from browser should be closed.

More info

In English

In Latvian

12. Networking
14. Unit testing
Izveidojis Valdis Vītoliņš 2017-01-03 10:07
Pēdējais mainījis Valdis Vītoliņš 2017-03-16 09:20
Xwiki Powered
Creative Commons Attribution 3.0 Unported License