[Jslib] SQL XPCOM Methods

Gordan Bobic gordan at bobich.net
Thu Apr 7 12:17:50 EDT 2005


Pete Collins wrote:
> 
>>
>>
>>> js> for (var list in Components.classes)
>>>      if (/sql/i.test(list))
>>>        print(list);
>>
>>
>>
>> That comes up empty. :-(
>>
> 
> Looks like there is no factory available ...
> 
> You should have seen
> 
>  @mozilla.org/sql/service;1
> 
> Also, you need to use jslibGetService
> 
> var obj = jslibGetService("@mozilla.org/sql/service;1", "mozISqlService");
> 
> But I doubt that will work if there is no factory available ...

Hurrah! Compiling from the latest source code made it work. :-)
Or at least, it made it work better:

Now xpcshell says:

js> for (var list in Components.interfaces)
      if (/sql/i.test(list))
        print(list);
mozISqlService
mozISqlResultEnumerator
mozISqlInputStream
mozISqlConnectionPgsql
mozISqlResult
mozISqlRequest
mozISqlRequestObserver
mozISqlDataSource
mozISqlResultPgsql
mozISqlConnection

js> for (var list in Components.classes)
      if (/sql/i.test(list))
        print(list);
@mozilla.org/sql/service;1
@mozilla.org/rdf/datasource;1?name=sql
@mozilla.org/sql/connection;1?type=pgsql

I've installed the static version of jslib, because it says that this is 
for use with XUL and XPCShell.

However, now I get the following:

js> var obj = jslibGetService("@mozilla.org/sql/service;1", 
"mozISqlService");

-----======[ jsLib ERROR ]=====-----
FileName:          chrome/jslib/jslib.js
Result:            -2153185302
Message:           Component returned failure code: 0x80570016 
(NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]
LineNumber:        100
-------------------------------------

What gives?

TIA.

Gordan


More information about the Jslib mailing list