SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.1
MySQL with Java
Ryusuke Kajiyama
MySQL Sales Consulting Senior Manager,
Asia Pacific & Japan
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2
“Connector/J”
JDBC Driver
of MySQL
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3
Connector/J	
§  Supports Java 5/6/7/8
§  Supports MySQL 5.0/5.1/5.5/5.6/5.7
§  Stable & mature 5.1 branch
–  Maintenance updates released approximately quarterly
§  Supports MySQL Fabric
–  Supports high-availability configurations
–  Load-balancing, failover, (multi-)master/slave replication
§  JMX-administration
§  Extensible
§  Much more!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4
	
Installation
§  One platform-independent download
§  The latest GA release
–  http://www.mysql.com/downloads/connector/j/
§  Deflate and extract the tar.gz or zip file
§  Add the library’s JAR file to your CLASSPATH
environment variable
–  For example
export set CLASSPATH=/opt/java/mysql-connector-java-5.1.36-bin.jar:$CLASSPATH
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14
Quick Load Balancer/Failover History Lesson
§  jdbc:mysql://primary,failover - since 3.0.2 (2002!)
–  From 5.1.13, this is a special case of jdbc:mysql://loadbalance under the
hood
§  jdbc:mysql:replication:// - since 3.1.11 (2005)
–  since 5.1.11, the slaves are a jdbc:mysql:loadbalance:// under the hood
§  jdbc:mysql:loadbalance:// - since 5.0.5 (2007)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15
Load-balancing/Failover Use Cases 	
§  Directly (jdbc:mysql:loadbalance:// URL prefix):
–  Clustered (NDB) or Multi-Master Replication deployment where both
read and write operations are distributed across all hosts.
§  Indirectly:
–  Replication deployments where read-only load can be distributed to
slaves (jdbc:mysql:replication://)
–  Deployments requiring strong server affinity for specific server, failing
over only when primary host is unavailable
(jdbc:mysql://primary,failover-1,failover-2...)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16
Fault Tolerance - Load Balancing/Failover
§  Load-balancing, failover is manageable
–  loadBalanceConnectionGroup=“name”
–  JMX – loadBalanceEnableJMX=true
–  In-VM via com.mysql.jdbc.ConnectionGroupManager
–  Add/remove hosts (gracefully or forcefully)
–  Get active hosts
–  Get inactive hosts
–  Get transaction counts
§  For more details:
http://dev.mysql.com/doc/connector-j/en/connector-j-multi-host-connections.html
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17
Controlling load-balance fail-over
§  Standard component
–  Communication exceptions
–  SQLState starting with “08”
–  User-defined SQLState list match – User-defined Class list match
§  Custom component
–  Implement LoadBalanceExceptionChecker interface
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18
StandardLoadBalanceExceptionChecker
properties
§  LoadBalanceSQLStateFailover
–  Comma-delimited list of SQLState values
–  Will match with trailing wildcard
§  “08” will match “08000” and “08S01”
§  loadBalanceSQLExceptionSubclassFailover
–  Comma-delimited list of fully-qualified class/interface names
–  Comparison using Class.isInstance(Exception)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19
Custom Exception Checker
§  Must implement LoadBalanceExceptionChecker
–  shouldExceptionTriggerFailover(SQLException ex) method
–  NDBLoadBalanceExceptionChecker example:
public class NdbLoadBalanceExceptionChecker extends
StandardLoadBalanceExceptionChecker {
public boolean shouldExceptionTriggerFailover(SQLException ex) {
return super.shouldExceptionTriggerFailover(ex) || checkNdbException(ex);
}
private boolean checkNdbException(SQLException ex) {
// Have to parse the message since most NDB errors are mapped to the same DEMC, sadly.
return (ex.getMessage().startsWith("Lock wait timeout exceeded") ||
(ex.getMessage().startsWith("Got temporary error")
&& ex.getMessage().endsWith("from NDB")));
}
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20
Security with SSL and
Pluggable
Authentication
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21
	
SSL in MySQL
§  MySQL Community built with yaSSL
§  MySQL Enterprise built with OpenSSL
§  MySQL 5.7 includes SSL improvements
–  Automatic SSL configuration with OpenSSL
§  Previous versions require manual configuration
–  Increased requirements for Diffie-Hellman key exchange
§  Key size minimum increased from 512 to 2048
–  Command line client requires SSL when --ssl is given
–  New mysql_ssl_rsa_setup utility
§  Requires OpenSSL to be installed
§  TLS 1.0
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.22
	
SSL Access Control
§  Any user can connect with SSL
§  MySQL 5.7 moves REQUIRE SSL et al to CREATE USER and ALTER
USER statements
–  Previously included with GRANT
§  Users created with REQUIRE SSL will be denied access when
connecting without SSL
§  Additional constraints available
–  REQUIRE X509
–  AND ISSUER ‘issuer’
–  AND SUBJECT ‘subject’
–  AND CIPHER ‘cipher’
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23
	
SSL in Connector/J
§  Encrypted communications
§  Establish identity of server
§  Allow server to establish identity of client
§  Required for regulatory and corporate policy compliance
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24
	
SSL Options in Connector/J
§  useSSL
§  requireSSL
§  verifyServerCertificate
§  clientCertificateKeyStoreUrl
§  clientCertificateKeyStoreType
§  clientCertificateKeyStorePassword
§  trustCertificateKeyStoreUrl
§  trustCertificateKeyStoreType
§  trustCertificateKeyStorePassword
§  enabledSSLCipherSuites
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25
	
Keys Used in SSL
§  Server public key in truststore
–  Can be specified as connection properties or Java system properties
javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword
–  Used to verify the server identity
–  Not needed if verifyServerCertificate=false
§  Client keypair in keystore
–  Can be specified as connection properties or Java system properties
javax.net.ssl.keyStore and javax.net.ssl.keyStorePassword
–  Used to prove client identity to the server
–  Client identity is not verified by default, use REQUIRE X509
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.27
	
Making SSL Connections
§  useSSL & requireSSL
–  useSSL enables SSL connections
–  requireSSL causes connections to abort if SSL is not supported
§  Importing keys with Java keytool
–  Check manual for tutorial:
§  Connector/J Reference
§  “Connecting Securely Using SSL”
–  keytool -import -alias mysqlServerCACert -file cacert.pem -
keystore keystore
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.28
	
Java 7 & MySQL 5.7 Community
§  MySQL 5.7 community uses Diffie-Hellman key exchange by default
§  Java 7 doesn’t support MySQL 5.7’s required 2048 bit key size for DH
key exchange
§  Exception will be thrown giving instructions
§  Force RSA key exchange with:
–  enabledSSLCipherSuites=
TLS_RSA_WITH_AES_128_CBC_SHA
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.29
	
Pluggable Authentication
§  New feature in MySQL 5.5
§  Supports traditional MySQL authentication and improved SHA-256
password hashing
§  Allows additional methods to be added with server plugins
§  Fully supported including extensible interfaces in Connector/J
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.32
Performance Tips
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.33
	
Bandwidth Considerations
§  Use fine-grained queries and avoid fetching unnecessary fields and
rows
§  Run tests with useUsageAdvisor=true to warn for inefficiencies
–  Reports on unused columns
–  Reports on result sets which were closed without reading all rows
§  Cache server configuration by setting
cacheServerConfiguration=true
–  Avoids additional querying during connection initialization
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.34
	
Buffered vs Streaming Results
§  Buffered results read entire result set into memory
–  Ala mysql_store_result()
–  Faster local access
–  Additional memory required
–  Best for OLTP applications
–  Fully scrollable cursors
§  Streaming results read individual rows as used
–  Ala mysql_use_result()
–  Access may be slowed while waiting for network reads
–  Reduced memory requirements
–  Best for very large results
–  Forward only scrollability
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.35
	
Enable Streaming Results
§  com.mysql.jdbc.Statement
–  Vender extension interface
§  Cast statement instances
§  Call enableStreamingResults()
§  Call disableStreamingResults()
§  Optionally set clobberStreamingResults=true
–  Result sets automatically closed when new statements are executed on the same
connections
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.62
• Use MySQL with Java
http://dev.mysql.com/usingmysql/java/
• Read Connector/J User Manual
http://dev.mysql.com/doc/refman/5.5/en/connector-j.html
• Visit MySQL “JDBC and Java” Forum
http://forums.mysql.com/list.php?39
• View MySQL Essentials Webinars (Part 1 – Part 5)
http://mysql.com/news-and-events/web-seminars/mysql-essentials.html
• Download MySQL 5.5
http://www.mysql.com/downloads/mysql/
• Download Free MySQL White Papers
http://dev.mysql.com/why-mysql/white-papers/
Learn More: Resources
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.63
5.6
MySQL Server - GA
The best release ever with high quality and performance
InnoDB NoSQL API and improved replication durability
MySQL Cluster - GA
200 Million NoSQL Reads/Second
Faster reboot operations and more detailed logs
7.4
5.7
MySQL Server - RC
Refactoring and adding more pluggable components
Faster performance and new NoSQL Features
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.64
The world's most popular open source database
世界でもっとも普及している、オープンソース データベース

Mais conteúdo relacionado

Mais procurados

Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best PracticesOracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Sven Sandberg
 
What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016
What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016
What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016
Geir Høydalsvik
 
Mysql User Camp : 20th June - Mysql New Features
Mysql User Camp : 20th June - Mysql New FeaturesMysql User Camp : 20th June - Mysql New Features
Mysql User Camp : 20th June - Mysql New Features
Tarique Saleem
 
2012 ohiolinuxfest replication
2012 ohiolinuxfest replication2012 ohiolinuxfest replication
2012 ohiolinuxfest replication
sqlhjalp
 

Mais procurados (20)

MySQL High Availibility Solutions
MySQL High Availibility SolutionsMySQL High Availibility Solutions
MySQL High Availibility Solutions
 
MySQL Tech Tour 2015 - 5.7 Whats new
MySQL Tech Tour 2015 - 5.7 Whats newMySQL Tech Tour 2015 - 5.7 Whats new
MySQL Tech Tour 2015 - 5.7 Whats new
 
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best PracticesOracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
 
MySQL Manchester TT - 5.7 Whats new
MySQL Manchester TT - 5.7 Whats newMySQL Manchester TT - 5.7 Whats new
MySQL Manchester TT - 5.7 Whats new
 
Why MySQL High Availability Matters
Why MySQL High Availability MattersWhy MySQL High Availability Matters
Why MySQL High Availability Matters
 
What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016
What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016
What's new in MySQL 5.7, Oracle Virtual Technology Summit, 2016
 
MySQL Enterprise Backup apr 2016
MySQL Enterprise Backup apr 2016MySQL Enterprise Backup apr 2016
MySQL Enterprise Backup apr 2016
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise Monitor
 
MySQL Security
MySQL SecurityMySQL Security
MySQL Security
 
MySQL 5.7: Focus on Replication
MySQL 5.7: Focus on ReplicationMySQL 5.7: Focus on Replication
MySQL 5.7: Focus on Replication
 
Mysql User Camp : 20th June - Mysql New Features
Mysql User Camp : 20th June - Mysql New FeaturesMysql User Camp : 20th June - Mysql New Features
Mysql User Camp : 20th June - Mysql New Features
 
NoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSONNoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSON
 
MySQL for Software-as-a-Service (SaaS)
MySQL for Software-as-a-Service (SaaS)MySQL for Software-as-a-Service (SaaS)
MySQL for Software-as-a-Service (SaaS)
 
MySQL Tech Tour 2015 - 5.7 InnoDB
MySQL Tech Tour 2015 - 5.7 InnoDBMySQL Tech Tour 2015 - 5.7 InnoDB
MySQL Tech Tour 2015 - 5.7 InnoDB
 
1 my sql20151219-kaji_ivan
1 my sql20151219-kaji_ivan1 my sql20151219-kaji_ivan
1 my sql20151219-kaji_ivan
 
2012 ohiolinuxfest replication
2012 ohiolinuxfest replication2012 ohiolinuxfest replication
2012 ohiolinuxfest replication
 
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
 
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB ClusterMySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
 
MySQL Tech Tour 2015 - 5.7 Security
MySQL Tech Tour 2015 - 5.7 SecurityMySQL Tech Tour 2015 - 5.7 Security
MySQL Tech Tour 2015 - 5.7 Security
 
MySQL User Camp: GTIDs
MySQL User Camp: GTIDsMySQL User Camp: GTIDs
MySQL User Camp: GTIDs
 

Destaque

MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20
MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20
MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20
Ryusuke Kajiyama
 
Shlideshare
ShlideshareShlideshare
Shlideshare
hyun
 

Destaque (13)

[Preview] MySQL session at Open Source Conference 2014 .Enterprise Osaka
[Preview] MySQL session at Open Source Conference 2014 .Enterprise Osaka[Preview] MySQL session at Open Source Conference 2014 .Enterprise Osaka
[Preview] MySQL session at Open Source Conference 2014 .Enterprise Osaka
 
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL 5.7
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL 5.7[db tech showcase 2015 Sapporo HOKKAIDO] MySQL 5.7
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL 5.7
 
[Java Küche RDB 最前線 2015] MySQL 5.7技術アップデート
[Java Küche RDB 最前線 2015] MySQL 5.7技術アップデート[Java Küche RDB 最前線 2015] MySQL 5.7技術アップデート
[Java Küche RDB 最前線 2015] MySQL 5.7技術アップデート
 
MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20
MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20
MySQL 5.7 & 最新開発状況 @ オープンソースカンファレンス20
 
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?
[db tech showcase 2015 Sapporo HOKKAIDO] MySQL as document database!?
 
Art of MySQL Replication.
Art of MySQL Replication.Art of MySQL Replication.
Art of MySQL Replication.
 
20150131 ChugokuDB-Shimane-MySQL
20150131 ChugokuDB-Shimane-MySQL20150131 ChugokuDB-Shimane-MySQL
20150131 ChugokuDB-Shimane-MySQL
 
第九回中国地方DB勉強会 in 米子 MySQL 5.7+
第九回中国地方DB勉強会 in 米子 MySQL 5.7+第九回中国地方DB勉強会 in 米子 MySQL 5.7+
第九回中国地方DB勉強会 in 米子 MySQL 5.7+
 
MySQLのNoSQL機能 - MySQL JSON & HTTP Plugin for MySQL
MySQLのNoSQL機能 - MySQL JSON & HTTP Plugin for MySQLMySQLのNoSQL機能 - MySQL JSON & HTTP Plugin for MySQL
MySQLのNoSQL機能 - MySQL JSON & HTTP Plugin for MySQL
 
MySQLチューニング
MySQLチューニングMySQLチューニング
MySQLチューニング
 
MySQL 5.7とレプリケーションにおける改良
MySQL 5.7とレプリケーションにおける改良MySQL 5.7とレプリケーションにおける改良
MySQL 5.7とレプリケーションにおける改良
 
Pi4Jで簡単! ラズパイでトイレ空室管理システムを つくってみたよ
Pi4Jで簡単!   ラズパイでトイレ空室管理システムを つくってみたよPi4Jで簡単!   ラズパイでトイレ空室管理システムを つくってみたよ
Pi4Jで簡単! ラズパイでトイレ空室管理システムを つくってみたよ
 
Shlideshare
ShlideshareShlideshare
Shlideshare
 

Semelhante a TWJUG August, MySQL JDBC Driver "Connector/J"

Semelhante a TWJUG August, MySQL JDBC Driver "Connector/J" (20)

MySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisationMySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisation
 
MySQL 5.7 + Java
MySQL 5.7 + JavaMySQL 5.7 + Java
MySQL 5.7 + Java
 
Netherlands Tech Tour 02 - MySQL Fabric
Netherlands Tech Tour 02 -   MySQL FabricNetherlands Tech Tour 02 -   MySQL Fabric
Netherlands Tech Tour 02 - MySQL Fabric
 
MySQL Fabric
MySQL FabricMySQL Fabric
MySQL Fabric
 
Oracle REST Data Services Best Practices/ Overview
Oracle REST Data Services Best Practices/ OverviewOracle REST Data Services Best Practices/ Overview
Oracle REST Data Services Best Practices/ Overview
 
2014 OpenSuse Conf: Protect your MySQL Server
2014 OpenSuse Conf: Protect your MySQL Server2014 OpenSuse Conf: Protect your MySQL Server
2014 OpenSuse Conf: Protect your MySQL Server
 
Mysql user-camp-march-11th-2016
Mysql user-camp-march-11th-2016Mysql user-camp-march-11th-2016
Mysql user-camp-march-11th-2016
 
MySQL Fabric - High Availability & Automated Sharding for MySQL
MySQL Fabric - High Availability & Automated Sharding for MySQLMySQL Fabric - High Availability & Automated Sharding for MySQL
MySQL Fabric - High Availability & Automated Sharding for MySQL
 
Changes in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowChanges in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must Know
 
Changes in weblogic12c_every_administrator_must_know-140812141929
Changes in weblogic12c_every_administrator_must_know-140812141929Changes in weblogic12c_every_administrator_must_know-140812141929
Changes in weblogic12c_every_administrator_must_know-140812141929
 
MySQL London Tech Tour March 2015 - MySQL Fabric
MySQL London Tech Tour March 2015 - MySQL FabricMySQL London Tech Tour March 2015 - MySQL Fabric
MySQL London Tech Tour March 2015 - MySQL Fabric
 
MySQL Tech Tour 2015 - 5.7 Connector/J/Net
MySQL Tech Tour 2015 - 5.7 Connector/J/NetMySQL Tech Tour 2015 - 5.7 Connector/J/Net
MySQL Tech Tour 2015 - 5.7 Connector/J/Net
 
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance Tuning
 
Introduction to MySQL
Introduction to MySQLIntroduction to MySQL
Introduction to MySQL
 
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
OUGLS 2016: Guided Tour On The MySQL Source Code
OUGLS 2016: Guided Tour On The MySQL Source CodeOUGLS 2016: Guided Tour On The MySQL Source Code
OUGLS 2016: Guided Tour On The MySQL Source Code
 
WebLogic 12c - OMF Canberra June 2014
WebLogic 12c - OMF Canberra June 2014WebLogic 12c - OMF Canberra June 2014
WebLogic 12c - OMF Canberra June 2014
 
MySQL Quick Dive
MySQL Quick DiveMySQL Quick Dive
MySQL Quick Dive
 

Mais de Ryusuke Kajiyama

Mais de Ryusuke Kajiyama (13)

[OSC 2020 Online/Nagoya] MySQLドキュメントストア
[OSC 2020 Online/Nagoya] MySQLドキュメントストア[OSC 2020 Online/Nagoya] MySQLドキュメントストア
[OSC 2020 Online/Nagoya] MySQLドキュメントストア
 
[OSC 2020 Osaka] MySQL"超"入門
[OSC 2020 Osaka] MySQL"超"入門[OSC 2020 Osaka] MySQL"超"入門
[OSC 2020 Osaka] MySQL"超"入門
 
[中国地方DB勉強会] 第22回 Webアプリ開発をデータベース側から変革していく - MySQL 8.0新機能
[中国地方DB勉強会] 第22回 Webアプリ開発をデータベース側から変革していく - MySQL 8.0新機能[中国地方DB勉強会] 第22回 Webアプリ開発をデータベース側から変革していく - MySQL 8.0新機能
[中国地方DB勉強会] 第22回 Webアプリ開発をデータベース側から変革していく - MySQL 8.0新機能
 
[OSC 2017 Tokyo/Fall] OSSコンソーシアム DB部会 MySQL 8.0
[OSC 2017 Tokyo/Fall] OSSコンソーシアム DB部会 MySQL 8.0[OSC 2017 Tokyo/Fall] OSSコンソーシアム DB部会 MySQL 8.0
[OSC 2017 Tokyo/Fall] OSSコンソーシアム DB部会 MySQL 8.0
 
[db tech showcase 2017 Tokyo] D31 - MySQL 8.0の日本語キャラクタ・セットと文字照合
[db tech showcase 2017 Tokyo] D31 - MySQL 8.0の日本語キャラクタ・セットと文字照合[db tech showcase 2017 Tokyo] D31 - MySQL 8.0の日本語キャラクタ・セットと文字照合
[db tech showcase 2017 Tokyo] D31 - MySQL 8.0の日本語キャラクタ・セットと文字照合
 
[db tech showcase 2017 Tokyo] A23 - MySQLのセキュリティ関連機能の現状
[db tech showcase 2017 Tokyo] A23 - MySQLのセキュリティ関連機能の現状[db tech showcase 2017 Tokyo] A23 - MySQLのセキュリティ関連機能の現状
[db tech showcase 2017 Tokyo] A23 - MySQLのセキュリティ関連機能の現状
 
2017年5月26日 オープンソースデータベース比較セミナー「NoSQLとしても使えるMySQLとMySQL Cluster」
2017年5月26日 オープンソースデータベース比較セミナー「NoSQLとしても使えるMySQLとMySQL Cluster」2017年5月26日 オープンソースデータベース比較セミナー「NoSQLとしても使えるMySQLとMySQL Cluster」
2017年5月26日 オープンソースデータベース比較セミナー「NoSQLとしても使えるMySQLとMySQL Cluster」
 
第20回 中国地方DB勉強会 in 岡山 MySQLレプリケーション
第20回 中国地方DB勉強会 in 岡山 MySQLレプリケーション第20回 中国地方DB勉強会 in 岡山 MySQLレプリケーション
第20回 中国地方DB勉強会 in 岡山 MySQLレプリケーション
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
 
State of the Dolphin, at db tech showcase Osaka 2014
State of the Dolphin, at db tech showcase Osaka 2014State of the Dolphin, at db tech showcase Osaka 2014
State of the Dolphin, at db tech showcase Osaka 2014
 
20140518 JJUG MySQL Clsuter as NoSQL
20140518 JJUG MySQL Clsuter as NoSQL20140518 JJUG MySQL Clsuter as NoSQL
20140518 JJUG MySQL Clsuter as NoSQL
 
2012.10.20 OSC 2012 Hiroshima
2012.10.20 OSC 2012 Hiroshima2012.10.20 OSC 2012 Hiroshima
2012.10.20 OSC 2012 Hiroshima
 
MySQL de NoSQL Fukuoka
MySQL de NoSQL FukuokaMySQL de NoSQL Fukuoka
MySQL de NoSQL Fukuoka
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

TWJUG August, MySQL JDBC Driver "Connector/J"

  • 1. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.1 MySQL with Java Ryusuke Kajiyama MySQL Sales Consulting Senior Manager, Asia Pacific & Japan
  • 2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2 “Connector/J” JDBC Driver of MySQL
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3 Connector/J §  Supports Java 5/6/7/8 §  Supports MySQL 5.0/5.1/5.5/5.6/5.7 §  Stable & mature 5.1 branch –  Maintenance updates released approximately quarterly §  Supports MySQL Fabric –  Supports high-availability configurations –  Load-balancing, failover, (multi-)master/slave replication §  JMX-administration §  Extensible §  Much more!
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4 Installation §  One platform-independent download §  The latest GA release –  http://www.mysql.com/downloads/connector/j/ §  Deflate and extract the tar.gz or zip file §  Add the library’s JAR file to your CLASSPATH environment variable –  For example export set CLASSPATH=/opt/java/mysql-connector-java-5.1.36-bin.jar:$CLASSPATH
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14 Quick Load Balancer/Failover History Lesson §  jdbc:mysql://primary,failover - since 3.0.2 (2002!) –  From 5.1.13, this is a special case of jdbc:mysql://loadbalance under the hood §  jdbc:mysql:replication:// - since 3.1.11 (2005) –  since 5.1.11, the slaves are a jdbc:mysql:loadbalance:// under the hood §  jdbc:mysql:loadbalance:// - since 5.0.5 (2007)
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15 Load-balancing/Failover Use Cases §  Directly (jdbc:mysql:loadbalance:// URL prefix): –  Clustered (NDB) or Multi-Master Replication deployment where both read and write operations are distributed across all hosts. §  Indirectly: –  Replication deployments where read-only load can be distributed to slaves (jdbc:mysql:replication://) –  Deployments requiring strong server affinity for specific server, failing over only when primary host is unavailable (jdbc:mysql://primary,failover-1,failover-2...)
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16 Fault Tolerance - Load Balancing/Failover §  Load-balancing, failover is manageable –  loadBalanceConnectionGroup=“name” –  JMX – loadBalanceEnableJMX=true –  In-VM via com.mysql.jdbc.ConnectionGroupManager –  Add/remove hosts (gracefully or forcefully) –  Get active hosts –  Get inactive hosts –  Get transaction counts §  For more details: http://dev.mysql.com/doc/connector-j/en/connector-j-multi-host-connections.html
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17 Controlling load-balance fail-over §  Standard component –  Communication exceptions –  SQLState starting with “08” –  User-defined SQLState list match – User-defined Class list match §  Custom component –  Implement LoadBalanceExceptionChecker interface
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18 StandardLoadBalanceExceptionChecker properties §  LoadBalanceSQLStateFailover –  Comma-delimited list of SQLState values –  Will match with trailing wildcard §  “08” will match “08000” and “08S01” §  loadBalanceSQLExceptionSubclassFailover –  Comma-delimited list of fully-qualified class/interface names –  Comparison using Class.isInstance(Exception)
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19 Custom Exception Checker §  Must implement LoadBalanceExceptionChecker –  shouldExceptionTriggerFailover(SQLException ex) method –  NDBLoadBalanceExceptionChecker example: public class NdbLoadBalanceExceptionChecker extends StandardLoadBalanceExceptionChecker { public boolean shouldExceptionTriggerFailover(SQLException ex) { return super.shouldExceptionTriggerFailover(ex) || checkNdbException(ex); } private boolean checkNdbException(SQLException ex) { // Have to parse the message since most NDB errors are mapped to the same DEMC, sadly. return (ex.getMessage().startsWith("Lock wait timeout exceeded") || (ex.getMessage().startsWith("Got temporary error") && ex.getMessage().endsWith("from NDB"))); } }
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20 Security with SSL and Pluggable Authentication
  • 12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21 SSL in MySQL §  MySQL Community built with yaSSL §  MySQL Enterprise built with OpenSSL §  MySQL 5.7 includes SSL improvements –  Automatic SSL configuration with OpenSSL §  Previous versions require manual configuration –  Increased requirements for Diffie-Hellman key exchange §  Key size minimum increased from 512 to 2048 –  Command line client requires SSL when --ssl is given –  New mysql_ssl_rsa_setup utility §  Requires OpenSSL to be installed §  TLS 1.0
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.22 SSL Access Control §  Any user can connect with SSL §  MySQL 5.7 moves REQUIRE SSL et al to CREATE USER and ALTER USER statements –  Previously included with GRANT §  Users created with REQUIRE SSL will be denied access when connecting without SSL §  Additional constraints available –  REQUIRE X509 –  AND ISSUER ‘issuer’ –  AND SUBJECT ‘subject’ –  AND CIPHER ‘cipher’
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23 SSL in Connector/J §  Encrypted communications §  Establish identity of server §  Allow server to establish identity of client §  Required for regulatory and corporate policy compliance
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24 SSL Options in Connector/J §  useSSL §  requireSSL §  verifyServerCertificate §  clientCertificateKeyStoreUrl §  clientCertificateKeyStoreType §  clientCertificateKeyStorePassword §  trustCertificateKeyStoreUrl §  trustCertificateKeyStoreType §  trustCertificateKeyStorePassword §  enabledSSLCipherSuites
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25 Keys Used in SSL §  Server public key in truststore –  Can be specified as connection properties or Java system properties javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword –  Used to verify the server identity –  Not needed if verifyServerCertificate=false §  Client keypair in keystore –  Can be specified as connection properties or Java system properties javax.net.ssl.keyStore and javax.net.ssl.keyStorePassword –  Used to prove client identity to the server –  Client identity is not verified by default, use REQUIRE X509
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.27 Making SSL Connections §  useSSL & requireSSL –  useSSL enables SSL connections –  requireSSL causes connections to abort if SSL is not supported §  Importing keys with Java keytool –  Check manual for tutorial: §  Connector/J Reference §  “Connecting Securely Using SSL” –  keytool -import -alias mysqlServerCACert -file cacert.pem - keystore keystore
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.28 Java 7 & MySQL 5.7 Community §  MySQL 5.7 community uses Diffie-Hellman key exchange by default §  Java 7 doesn’t support MySQL 5.7’s required 2048 bit key size for DH key exchange §  Exception will be thrown giving instructions §  Force RSA key exchange with: –  enabledSSLCipherSuites= TLS_RSA_WITH_AES_128_CBC_SHA
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.29 Pluggable Authentication §  New feature in MySQL 5.5 §  Supports traditional MySQL authentication and improved SHA-256 password hashing §  Allows additional methods to be added with server plugins §  Fully supported including extensible interfaces in Connector/J
  • 20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.32 Performance Tips
  • 21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.33 Bandwidth Considerations §  Use fine-grained queries and avoid fetching unnecessary fields and rows §  Run tests with useUsageAdvisor=true to warn for inefficiencies –  Reports on unused columns –  Reports on result sets which were closed without reading all rows §  Cache server configuration by setting cacheServerConfiguration=true –  Avoids additional querying during connection initialization
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.34 Buffered vs Streaming Results §  Buffered results read entire result set into memory –  Ala mysql_store_result() –  Faster local access –  Additional memory required –  Best for OLTP applications –  Fully scrollable cursors §  Streaming results read individual rows as used –  Ala mysql_use_result() –  Access may be slowed while waiting for network reads –  Reduced memory requirements –  Best for very large results –  Forward only scrollability
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.35 Enable Streaming Results §  com.mysql.jdbc.Statement –  Vender extension interface §  Cast statement instances §  Call enableStreamingResults() §  Call disableStreamingResults() §  Optionally set clobberStreamingResults=true –  Result sets automatically closed when new statements are executed on the same connections
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.62 • Use MySQL with Java http://dev.mysql.com/usingmysql/java/ • Read Connector/J User Manual http://dev.mysql.com/doc/refman/5.5/en/connector-j.html • Visit MySQL “JDBC and Java” Forum http://forums.mysql.com/list.php?39 • View MySQL Essentials Webinars (Part 1 – Part 5) http://mysql.com/news-and-events/web-seminars/mysql-essentials.html • Download MySQL 5.5 http://www.mysql.com/downloads/mysql/ • Download Free MySQL White Papers http://dev.mysql.com/why-mysql/white-papers/ Learn More: Resources
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.63 5.6 MySQL Server - GA The best release ever with high quality and performance InnoDB NoSQL API and improved replication durability MySQL Cluster - GA 200 Million NoSQL Reads/Second Faster reboot operations and more detailed logs 7.4 5.7 MySQL Server - RC Refactoring and adding more pluggable components Faster performance and new NoSQL Features
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.64 The world's most popular open source database 世界でもっとも普及している、オープンソース データベース