Page tree

자주 잊어버리니 기록!


Download

$ wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.47.tar.gz


maven

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.47</version>
</dependency>


JDBC Driver class

com.mysql.jdbc.Driver

JDBC URL format

jdbc:mysql://[host][,failoverhost...][:port]/[database][?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...


property file용

jdbc:mysql://localhost:3306/lesstif?useUnicode=true&characterEncoding=utf8


XML용

& 가 특수 문자이므로 &amp; 로 변경

jdbc:mysql://localhost:3306/lesstif?useUnicode=true&amp;characterEncoding=utf8
  • useUnicode 의 기본 설정은 true 이므로 빼도 된다.
  • characterEncoding 의 기본 설정은 'autodetect' 다.

Spring DataSource 용

<bean id="myDS"
		class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="url" value="jdbc:mysql://localhost:3306/lesstif?useUnicode=true&amp;characterEncoding=utf8" />
		<property name="username" value="userid" />
		<property name="password" value="useriduserPwd" />
	</bean> 


Ref