Gregg Reynolds wrote:
Hi,
I can't seem to get getConnection to work with the SQLite component. Any pointers would be appreciated.
Can you post minimal sample code that demonstrates what you're doing with the API, what behaviour you're seeing, and what behaviour you're expecting?
Without that, all I can offer in the way of pointers is http://lxr.mozilla.org/mozilla/source/calendar/providers/storage/ as an example of usage that works quite well.
Mike
Thanks. I looked at the url but I don't see where the connection gets set up; it doesn't look anything like what I'm trying. I'm using some code that somebody posted as an example at XULPlanet:
function doConnect()
{
var sqlService = Components.classes["@mozilla.org/sql/service;1"].
getService(Components.interfaces.mozISqlService); var alias = sqlService.getAlias("foo");if (!alias){
alias = sqlService.addAlias("test","sqlite", "localhost","","/d/work/sqlite/test.db",0);
}
try {
connection = sqlService.getConnection(alias);
}
catch (ex) {
alert("sqlService.getConnection exception");
return;
}
alert("connect ok");
...etc...I always get the alert "sqlService.getConnection exception"; naturally the exception itself has no useful information. But if I alert(alias) after adding it, it says "xpconnect wrapped nsIRDFResource", so I guess the alias is obtained ok.
What I'm not sure about is what to use for the 'type' parm (looking at the source I think 'sqlite' but who knows?) and for the database. I'm new to both sqlite and xul/xpcom so I'm floundering a bit. I've tried every syntax I can think of for the db name parm, with no luck.
My sqlite3.exe is in /usr/bin, included in the path. I also have /d/opt/sqlite3 which is where both sqlite3.exe and sqlite3.dll live. sqlite3.h lives in /d/dev/sqlite3. Compiling mozilla on win2k I used the following .mozconfig file:
========== .mozconfig start . $topsrcdir/browser/config/mozconfig mk_add_options [EMAIL PROTECTED]@/../moz-bld ac_add_options --enable-optimize ac_add_options --disable-debug ac_add_options --enable-static ac_add_options --disable-shared ac_add_options --disable-tests
ac_add_options --enable-extensions=default,sql
export BUILD_OFFICIAL=1 export MOZILLA_OFFICIAL=1 export MOZ_ENABLE_SQLITE=1 export MOZ_SQLITE_INCLUDES=/d/dev/sqlite/include export MOZ_SQLITE_LIBS=/d/opt/sqlite3/
mk_add_options BUILD_OFFICIAL=1 mk_add_options MOZILLA_OFFICIAL=1
ac_add_options --disable-activex ac_add_options --disable-activex-scripting
======end of .mozconfig
Any hints would be great; I'm getting quite frustrated with the whole thing.
thanks,
gregg _______________________________________________ Mozilla-xpcom mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-xpcom
