Skip to content

Latest commit

 

History

History
70 lines (45 loc) · 3.19 KB

File metadata and controls

70 lines (45 loc) · 3.19 KB

JAVA_MySQL_Connectivity for BCA Second Years, Bharata Mata College (Autonomous), Thrikkakara

This repository Java_MySQL_Connectivity contains instructions for testing Java MySQL Connectivity using JDBC. Files to run (in src): Main.java : Program for testing Java MySQL Connectivity using JDBC NewMain.java : Program to create a table in user specified MySQL Database and insert two rows.

MAKE SURE YOU HAVE MySQL INSTALLED IN YOU SYSTEM!

INSTRUCTIONS TO SETUP IntelliJ, JDBC with MySQL as backend.

Step 1: Download IntelliJ IDE by Jet Brains https://www.jetbrains.com/idea/download/?section=windows

Choose .exe (Windows) and click Download

image

Run the .exe file.

NOTE: Do not forget to choose add to PATH while installing!

Download JDBC https://dev.mysql.com/downloads/connector/j/

image

Choose Operating System as Platform Independent.

JDBC_OS

Choose the .zip option

Arc_4CElC7dIH4

Extract the file and save it in the Desktop.

Download this repository Java_MySQL_Connectivity. Extract the zip file. Open the folder JAVA_MySQL with IntelliJ IDE.

Hit Ctrl+Alt+Shift+S. In the Dialog Box, on the left side click on Modules, then click on Dependencies, on the + Symbol. Select option 1, JAR or Directories. Navigate to the file, the JDBC file mysql-connector-j-9.5.0 Select the file mysql-connector-j-9.5.0.jar.

Before running the program make sure you have entered the database name and MySQL Password. Run the program file Main.java in src folder. If you get the output as

image

You are now connected to MySQL. IntelliJ is communicating with MySQL. Congrats! You now have a working Java with MySQL Backend.

INSERT

Check the NewMain.java file The program NewMain.java in src folder contains code for creating a table in user specified MySQL database and insert two entries. Run the file and if you get the output as

image

You have created a table >users in the database that you have specified and two entries have been inserted.

You can also verify the table created in MySQL Client. image

NOTE: You must only run this program once as running it the second time causes errors, since the data will be duplicated.

The code is generated with the help of Google Gemini.