java.sql.SQLException: No suitable driver found for dbc:mysql://localhost

조회 수: 47 (최근 30일)
Deborah
Deborah 2011년 8월 9일
답변: line hammer 2021년 6월 21일
I'm getting the error: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost
I have mysql-connector-java-5.1.14-bin.jar in my javaclasspath. I'm using the following code:
>> url = java.lang.String(['jdbc:mysql://localhost:3306']); >> db_conn = DriverManager.getConnection (url); ??? Java exception occurred: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
This worked for me previously, but not anymore! Anybody have any ideas? Thanks much Debbie

답변 (2개)

Deborah
Deborah 2011년 8월 9일
Follow-up: just checked my old notes. I had to copy mysql-connector-java-5.1.14-bin.jar to MATLAB_JAVA/jre/lib/ext to get this to work!
  댓글 수: 2
Chirag Gupta
Chirag Gupta 2011년 8월 9일
You can also just do a javaaddpath('location of sqlconnector.jar')
Ali Esmaili
Ali Esmaili 2020년 5월 7일
I have done this on Matlab 2019b and it is not working. I am able to add the data source into the javaaddpath but it has no effect.

댓글을 달려면 로그인하십시오.


line hammer
line hammer 2021년 6월 21일
The reason you got this error is because you forgot to register your java mysql jdbc driver with the application.
Should be like this:
Class.forName("com.mysql.jdbc.Driver");
This forces the driver to register itself, so that Java knows how to handle those database connection strings.
You'll have to read the manual on your specific mysql jdbc driver to find the exact string to place inside the the Class.forName("...") parameter.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by