How to connect Java to MySql Database

0 votes
Hi. Can someone send me the code to connect Java pogram to MySql Database?
Aug 27, 2019 in Java by Krish
1,151 views

1 answer to this question.

0 votes

This will work:

try {

         Class.forName("com.mysql.cj.jdbc.Driver");

         Connection con = DriverManager.getConnection("jdbc:mysql://localhost/mysql?user=root&password=edureka");

  }

  catch (Exception ex) {

         ex.printStackTrace();

  }
answered Aug 27, 2019 by John

Related Questions In Java

0 votes
1 answer

How to connect Java program to the MySQL database?

You can connect your Java code with ...READ MORE

answered May 11, 2018 in Java by Parth
• 4,640 points
1,929 views
+1 vote
1 answer

How to create database in MySql using Java?

First, you will have to create connection ...READ MORE

answered Sep 30, 2019 in Java by Shri
3,321 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 81,372 views
0 votes
2 answers

How can I convert a String variable to a primitive int in Java

 Here are two ways illustrating this: Integer x ...READ MORE

answered Aug 20, 2019 in Java by Sirajul
• 59,230 points
2,354 views
0 votes
1 answer

Accessing connection from different class in Java / MySQL?

You should just instantiate DoComms with every ...READ MORE

answered Nov 14, 2018 in Database by nirvana
• 3,130 points
1,983 views
0 votes
3 answers

MySQL "Could not create connection to database serve" error

Pls check that you have MySQL server ...READ MORE

answered Jul 3, 2020 in Database by anonymous
29,959 views
0 votes
1 answer

Java and MySql: Check if database exists

You can get the list of databases ...READ MORE

answered Aug 27, 2019 in Java by Kunal
4,553 views
0 votes
1 answer

Java and MySql: Delete database if exists

First, you have to check if the ...READ MORE

answered Aug 27, 2019 in Java by Varun
847 views
0 votes
1 answer

How to connect Java to MySql Database?

Make sure you have the MySQL jdbc ...READ MORE

answered Sep 30, 2019 in Java by Shyam
1,455 views
0 votes
1 answer

How to create database in MySql using Java?

First, you will have to create connection ...READ MORE

answered Aug 27, 2019 in Java by Juni
772 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP