org.hibernate.cfg.AvailableSettings
hibernate.show_sql
hibernate.format_sql
hibernate.highlight_sql
hibernate.session.events.log.LOG_QUERIES_SLOWER_THAN_MS
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) {}
}
}
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
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
)
프로그래밍 초식 : 초심자가 저지르기 쉬운 DB 코딩 실수 3가지
Connection
을 얻고 반납할 때는...DataSourceUtils
를 사용해야 Transaction 전파가 가능함