Connect to DB with Java

Long time no see. This is Haru-chan. Now that I have a chance to touch Servlet, I would like to explain how to connect to MySQL with Java. Things necessary

--Java development environment (here Eclipse)

Since I use Mamp, I will download Mamp. https://www.mamp.info/en/

The setting is https://techacademy.jp/magazine/5102 I think you can do it while checking here.

after https://dev.mysql.com/downloads/connector/j/ Download this and you're ready to go.

Actually move on to work First of all, create a file with eclipse. スクリーンショット 2018-03-25 19.08.47.png Copy mysql-connector-java-5.1.46-bin.jar to the lib file in this way. Then select the build path configuration Select Add JAR for Library. Screenshot 2018-03-25 19.13.46.png The screen will switch to the selection screen, so select mysql-connector-java-5.1.46-bin.jar in the lib file and adapt it. Then, the reference library will appear in this form. At this point, the environment for connecting to the database is ready! スクリーンショット 2018-03-25 19.15.44.png

Connect to the database. スクリーンショット 2018-03-25 19.23.55.png Exception handling is output when an exception occurs in try {} catch.

https://www.youtube.com/watch?v=2HTZYPVHTBs&index=1&list=LL-FDeuuQwmD9u4WIukMq-3g&t=0s I connected by myself referring to this video. Since there is no article to connect with mamp, I think that it is better to set based on this.

Recommended Posts

Connect to DB with Java
Connect to MySQL 8 with Java
[Java] Connect to MySQL
Java to play with Function
Try DB connection with Java
Connect from Java to PostgreSQL
Connect to oracle with eclipse!
Operation to connect multiple Streams @Java
Java to learn with ramen [Part 1]
[Java] Points to note with Arrays.asList ()
Dare to challenge Kaggle with Java (1)
I tried to interact with Java
Connect to Rails server with iPhone
Java, arrays to start with beginners
Connect to Amazon EC2 with SSH (Ubuntu)
How to compile Java with VsCode & Ant
[Java] How to compare with equals method
Introduction to algorithms with java --Search (depth-first search)
Connect from Java to MySQL using Eclipse
[Java] Introduction to Java
Introduction to java
Easy to trip with Java regular expressions
Introduction to algorithms with java --Search (breadth-first search)
[Java] How to test for null with JUnit
Upsert from Java SDK to Azure Cosmos DB
I tried to make Basic authentication with Java
Introduction to algorithms with java --Search (bit full search)
Deploy Java web app to Azure with maven
Try to link Ruby and Java with Dapr
How to use Java framework with AWS Lambda! ??
I want to use java8 forEach with index
How to use Java API with lambda expression
Getting started with Kotlin to send to Java developers
Try to implement TCP / IP + NIO with JAVA
[Java / PostgreSQL] Connect the WEB application to the database
[Java] Article to add validation with Spring Boot 2.3.1.
Easy to make LINE BOT with Java Servlet
I tried to break a block with java (1)
Select * from Java SDK to Azure Cosmos DB
Install java with Homebrew
JAVA DB connection method
Change seats with java
Solution that gives an error when trying to connect to DB (MySQL) in Java
Install Java with Ansible
Comfortable download with JAVA
[Java] DB migration (Flyway)
[Java] I tried to connect using a connection pool with Servlet (tomcat) & MySQL & Java
Switch java with direnv
Kotlin's improvements to Java
From Java to Ruby !!
Download Java with Ansible
Let's scrape with Java! !!
Introduction to java command
Build Java with Wercker
Endian conversion with JAVA
[Java] [SQL Server] Connect to local SQL Server 2017 using JDBC for SQL Server
How to call functions in bulk with Java reflection
List processing to understand with pictures --java8 stream / javaslang-
Submit a job to AWS Batch with Java (Eclipse)
How to connect MySQL / MariaDB + HikariCP with Liferay 7 / DXP
I tried to implement TCP / IP + BIO with JAVA