Hibernate Settings Location, Notifiable config properties

org.hibernate.cfg.AvailableSettings

hibernate.show_sql
hibernate.format_sql
hibernate.highlight_sql
hibernate.session.events.log.LOG_QUERIES_SLOWER_THAN_MS

Low-level code

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcConnection {
	public static void main(String[] args) {
		try {
			Class.forName("com.mysql.cj.jdbc.Driver");
			Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/local_neogeo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false", "username", "password");
			Statement stmt = con.createStatement();
			System.out.println("Created DB Connection...");
		} catch (ClassNotFoundException e) {
		} catch (SQLException e) {}
	}
}

MySQL

implementation 'mysql:mysql-connector-java'
spring:
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:mysql://localhost:3306/local_neogeo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false
    username: root
    password: secret
    driver-class-name: com.mysql.cj.jdbc.Driver
    hikari:
      poolName: Hikari
      auto-commit: false
  jpa:
    open-in-view: false
    hibernate:
      ddl-auto: none
      naming:
        physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
        implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
    properties:
      hibernate:
        jdbc:
          batch_size: 100
          batch_versioned_data: true
        order_inserts: true
        order_updates: true

H2

implementation 'com.h2database:h2'
spring:
	datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:mem:local_neogeo;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
    # jdbc:h2:file:./build/h2db/deliverybundler;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
    # jdbc:h2:file:./build/h2db/deliverybundler;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MULTI_THREADED=FALSE
    username: sa
    password:

  jpa:
    properties:
      hibernate:
        show_sql: true
        format_sql: true
create table customer (
	id serial primary key,
	name varchar(255) not null
)

https://gist.githubusercontent.com/appkr/12043697c04855ff413f136e62b8e79b/raw/1502610cdae955ceb904cb36cda2331b3bb67952/h2.png

초심자가 저지르기 쉬운 DB 코딩 실수 3가지

프로그래밍 초식 : 초심자가 저지르기 쉬운 DB 코딩 실수 3가지

JDBC 주의점