Connecting to database
8 ビュー (過去 30 日間)
古いコメントを表示
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
2011 年 4 月 19 日
Check with javaclasspath that the path was added correctly. All the patsh should look stacked.
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!