connecting sqllite database from command line

1 回表示 (過去 30 日間)
Rashmil Dahanayake
Rashmil Dahanayake 2014 年 10 月 15 日
コメント済み: Rashmil Dahanayake 2014 年 10 月 15 日
HI, I'm using following commands to make a connection to sqllite database. The object variable conn.Message, appears to be -> 'invalid database address: URLc:\scripts\database\test.db'
dbpath='c:\scripts\database\test.db';
URL='jdbc:sqlite:c:\scripts\database\test.db';
conn = database(dbpath,'','','org.sqlite.JDBC','URL');
How can I correct above code to connect and ping.
PS: dexplore GUI works fine.But I need to do it in a script. I have installed sqllite-jdbc jar and path added.

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 10 月 15 日
Note the line of code
conn = database(dbpath,'','','org.sqlite.JDBC','URL');
The last parameter that is passed is a string with the contents URL, rather than the string variable URL, so the error message appears to be taking that value of 'URL' and concatenating with the dbpath to get
URLc:\scripts\database\test.db
What you want to do instead, is to remove the single quotes around URL and create the connection as
conn = database(dbpath,'','','org.sqlite.JDBC',URL);
Try the above and see what happens. It may be that you encounter another error and so might have to reset dbpath to an empty string so that your connection becomes simply
conn = database('','','','org.sqlite.JDBC',URL);
See the last point from SQLite JDBC for Windows for details.
  1 件のコメント
Rashmil Dahanayake
Rashmil Dahanayake 2014 年 10 月 15 日
extra quotes caused the error

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by