Connecting to database

조회 수: 3 (최근 30일)
Oyinda
Oyinda 2011년 4월 19일
After setting the classpath for JDBC I did a test drive. The output was:
Current JDBC Drivers: null
sun.jdbc.odbc.JdbcOdbcDriver@723d7c
I have also made changes to my classpath.txt by adding this at the end.
C:/Program Files (x86)/Java/mysql-connector-java-5.1.15/mysql-connector-java-5.1.15-bin.jar
so i did all this.
>> url = 'jdbc:mysql://localhost/test';
>> conn = database('characters', 'root', '', 'com.mysql.jdbc.Driver', url);
>> conn
conn =
Instance: 'characters'
UserName: 'root'
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: [1x66 char]
Handle: 0
TimeOut: []
AutoCommit: 'off'
Type: 'Database Object'
>> ping(conn)
??? Error using ==> database/ping
Cannot pass a null connection handle
But I get this error. What is happening and how can I solve it?
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 4월 19일
Check with javaclasspath that the path was added correctly. All the patsh should look stacked.

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

답변 (1개)

Chirag Gupta
Chirag Gupta 2011년 4월 19일
Expand the Message field in the conn object. This will give you the actual reported error. For a successful connection, you will notice that the Message field is empty.
Typically the jdbc url for mysql is:
jdbc:mysql://<machine>:<port>/databasename');
I am guessing it should be: jdbc::mysql://localhost:3306/characters
Where 3306 is the general default port for mySQl

카테고리

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