[go: up one dir, main page]

0% found this document useful (0 votes)
19 views11 pages

Database Systems Midterm L1

Uploaded by

maglangitmarvinc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views11 pages

Database Systems Midterm L1

Uploaded by

maglangitmarvinc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

JDBC - Connecting MySql

to Java
Instructor: Michael Ray V. Alvina
Connecting to Java
In order to connect MySql to Eclipse, these steps are necessary:

● Download the connector


Connecting to Java
In order to connect MySql to Eclipse, these steps are necessary:

● Go to your java Eclipse project >properties> buildpath


Connecting to Java
In order to connect MySql to Eclipse, these steps are necessary:

● Select Modulepath and then click add External JARs


Connecting to Java - In MySql
In order to connect MySql to Eclipse, these steps are necessary:

● In MySql, click the create a new Schema button


Connecting to Java - In MySql
In order to connect MySql to Eclipse, these steps are necessary:

● In MySql, click the create a new Schema button, name it and select apply
Connecting to Java
In order to connect MySql to Eclipse, these steps are necessary:
● Basic information:
○ Driver class: The driver class for the mysql database is com.mysql.cj.jdbc.Driver.
○ Connection URL: The connection URL for the mysql database is
jdbc:mysql://localhost:3306/testdb where:

● Jdbc is the API


● mysql is the database
● localhost is the server name on which mysql is running
● 3306 is the port number
● testdb is the database name
Connecting to Java - Coding Phase
In order to connect MySql to Eclipse, these steps are necessary:

● Declare the following:

● Where:
○ The url is the location of your database.
○ dbUsername & dbPassword is your mySql username and password (default being
“root”)
Connecting to Java - Coding Phase
In order to connect MySql to Eclipse, these steps are necessary:

● Create a try - catch statement to connect to your database.


Connecting to Java
In order to connect MySql to Eclipse, these steps are necessary:

● Download the connector


Connecting to Java - Running the program
● If all the necessary steps are done correctly, the project must run without
problems, and the connection to the database will be successful.

You might also like