Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

Can anyone help me how I can able to connect Java to MySQL Database. When I tried to connect it, it is giving me something like this:

java.sql.SQLException: No suitable driver found for jdbc:mysql://database/table

    at java.sql.DriverManager.getConnection(DriverManager.java:689)

    at java.sql.DriverManager.getConnection(DriverManager.java:247)

Any help would be appreciated.

1 Answer

0 votes
by (26.7k points)

Basically, you can use DataSource as DriverManger is become old for these things:

Context context = new InitialContext();

DataSource dataSource = (DataSource) context.lookup("java:comp/env/jdbc/myDB");

I hope this will help.

Want to become a Java Expert? Join Java Training now!!

Want to know more about Java? Watch this video on Java Tutorial | Java Course:

Related questions

0 votes
1 answer
asked Aug 20, 2019 in Java by Krishna (2.6k points)
0 votes
0 answers
asked Feb 17, 2021 in Java by Harsh (1.5k points)
0 votes
1 answer
+3 votes
2 answers

Browse Categories

...