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. 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. 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!
Connect to the database. 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