MySQL Database connection in Java using Eclipse || Login page Example || English

Опубликовано: 25 Январь 2018
на канале: Technical Babaji
334,561
3.6k

Check out this article if you have still doubt. you can copy-paste code as well


download mysql-connector.jar file
https://goo.gl/ftjWmK

if this video really helped you then you can help me out by Donatation me on PayPal paypal.me/Tarique1

For connecting java application with the mysql database, you need to follow 5 steps to perform database connectivity.

In this example we are using MySql as the database. So we need to know following informations for the mysql database:

Driver class: The driver class for the mysql database is com.mysql.jdbc.Driver.
Connection URL: The connection URL for the mysql database is jdbc:mysql://localhost:3306/test where jdbc is the API, mysql is the database, localhost is the server name on which mysql is running, we may also use IP address, 3306 is the port number and test is the database name. We may use any database, in such case, you need to replace the test with your database name.
Username: The default username for the mysql database is root.
Password: The default password for the mysql database is ""(blank).Password is given by the user at the time of installing the mysql database. In this example, we are going to use "" as the password.
Let's first create a table in the mysql database, but before creating table, we need to create database first.

create database test;
use test;
create table tblogin(UserName varchar(10),Password varchar(40));




-----------------------------------
The above example will fetch all the records of tblogin table.

To connect java application with the mysql database mysqlconnector.jar file is required to be loaded.

download the jar file mysql-connector.jar
Two ways to load the jar file:
paste the mysqlconnector.jar file in jre/lib/ext folder
set classpath
1) paste the mysqlconnector.jar file in JRE/lib/ext folder:
Download the mysqlconnector.jar file. Go to jre/lib/ext folder and paste the jar file here.
2) set classpath:
There are two ways to set the classpath:
temporary
permanent
How to set the temporary classpath
open command prompt and write:
C: set classpath=c:\folder\mysql-connector-java-5.0.8-bin.jar;.;
How to set the permanent classpath
Go to environment variable then click on new tab. In variable name write classpath and in variable value paste the path to the mysqlconnector.jar file by appending mysqlconnector.jar;.; as C:\folder\mysql-connector-java-5.0.8-bin.jar;.;

~-~~-~~~-~~-~
Please watch: "MySQL Database connection in java 12 using eclipse 2019"
   • MySQL Database connection in java 12 ...  
~-~~-~~~-~~-~


Смотрите видео MySQL Database connection in Java using Eclipse || Login page Example || English онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Technical Babaji 25 Январь 2018, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 334,561 раз и оно понравилось 3.6 тысяч людям.