Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 19
Registered: ‎11-02-2010
My Device: Not Specified

BB Torch and sqlite/http connection

[ Edited ]

I am writing a Web Widget using the BlackBerry Web Plug-in for Eclipse(v2.5) and the Widget SDK (v1.5).

 

The application includes a sqlite db to keep track of whether the user wishes to receive push notifications or not.  When opening the DB connection on a live device(the new torch), i get this error:

 

err.name:  INVALID_STATE_ERR

err.message:  INVALID_STATE_ERR: DOM Exception 11

 

i find that this occurs after formatting the media card.  Here is my db connection code:

 

 

 

function openDB() {
   try {
     var dbSize = 1 * 1024 * 1024;
     var db = openDatabase("myDb", "1.0", "myDb", dbSize);
     if(db) {
       db.transaction(function(tx) {
        tx.executeSql("CREATE TABLE IF NOT EXISTS notifications (id INTEGER PRIMARY KEY, allow INTEGER)");
         tx.executeSql("SELECT allow FROM notifications", null, loadNotif);
       });
     _db = db;
     }
     else
       alert("no db");
  }
   catch(e) {
     alert(e.name + "-----" + e.message);
   }
}
Also, when trying to send a HttpRequest to a remote server, it is giving me an error code 101(i think this means it isn't allowed to request the site?).  here is the request function:
function execHttpRequest(url, method) {
   try {
     httpReq.onreadystatechange = handleStateChange;
     httpReq.open(method, url, false);
     httpReq.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");
     httpReq.setRequestHeader("Pragma", "cache");
     httpReq.setRequestHeader("Cache-Control", "no-transform");
     httpReq.send();
       if(httpReq.readyState == 4 && httpReq.status == 200)
         return httpReq.responseText;
       else
         return "no response";
     }
     catch(err) {
       alert(err.name + " " + err.message);
     }
   return "no response";
}
function handleStateChange() {
   if(httpReq.readyState != 4)
     return;
}
How do I fix my database connection problem?
Why is this happening?
How can i request an Http connection to a remote site in the background? the Weather application's code for making an httprequest does not work on a real device

 

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: BB Torch and sqlite/http connection

Hi binnyb,

 

Can you post up the exact OS version of 6.0.0.x that you are using?  As well is the device connected via WiFi or the carrier connection?  Also, is the device connected to a corporate BES?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 19
Registered: ‎11-02-2010
My Device: Not Specified

Re: BB Torch and sqlite/http connection

torch 9800

6.0 Bundle 695 (v6.0.0.246, Platform 6.4.0.105)

both wifi and regular at&t service

 

curve 9300

v5.0.0.955 (Bundle 1576, Platform 6.3.0.57)

just wifi

 

both devices not connected to a corporate BES

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: BB Torch and sqlite/http connection

Have you been able to verify which statement or line of code is causing the error?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 19
Registered: ‎11-02-2010
My Device: Not Specified

Re: BB Torch and sqlite/http connection

[ Edited ]

When i try to open the database: openDatabase("myDb", "1.0", "myDb", dbSize);

 

it throws an exception with the err name and message i have printed in the original post(only after formatting the media card).  note that this is not the case on the curve, only the torch.

 

for the httprequest the error i get in the catch block is: 

NETWORK_ERR NETWORK_ERR: XMLHttpRequest Exception 101

 

the execHttpRequest function always returns "no response"

 

edit: also note that my url has many parameters being sent with it:

 

var pin = blackberry.identity.PIN;
var appName = blackberry.app.name;
var appVersion = blackberry.app.version;
var deviceToken = "NULL";
var deviceName = "NULL";
var model = blackberry.system.model;
var version = blackberry.system.softwareVersion;
var pushBadge = "NULL";
var pushAlert = "NULL";
var pushSound = "NULL";
var pushUrlArgs = "?appname=" + appName + "&appversion=" + appVersion + "&task=register" + 
"&deviceuid=" + pin + "&devicetoken=" + deviceToken + "&devicename=" + deviceName + 
"&devicemodel=" + model + "&deviceversion=" + version + "&pushbadge=" + pushBadge + 
"&pushalert=" + pushAlert + "&pushsound=" + pushSound;
so i call execHttpRequest like this:
alert("response: " + execHttpRequest('http://www.mysite.com/myscript.php' + pushUrlArgs, "POST"));

 

Contributor
Posts: 12
Registered: ‎10-06-2010
My Device: Not Specified

Re: BB Torch and sqlite/http connection

I'm not sure that this is cause of the http request error, but it looks like you should be using GET instead of POST.

 

POST method will send the parameters separate from the url.


www.lionbridge.com
Contributor
Posts: 19
Registered: ‎11-02-2010
My Device: Not Specified

Re: BB Torch and sqlite/http connection

i have tried replacing POST with GET and i get the same error message.

Contributor
Posts: 12
Registered: ‎10-06-2010
My Device: Not Specified

Re: BB Torch and sqlite/http connection

 I did not see in your code snippet if you do the following:

 

  var  htttpReq = new XMLHttpRequest();

 

 As this will need to be done at least once before you can successfully make a request.

 With your code doing the request synchronously you might went to make a new XMLHttpRequest with each request.

 


www.lionbridge.com
Contributor
Posts: 19
Registered: ‎11-02-2010
My Device: Not Specified

Re: BB Torch and sqlite/http connection

I failed to mention that i have a global httpReq variable which is initialized.  I have tried creating a new XMLHttpRequest for each request i make, no luck - same error.  I get the same error running it in a regular computer web browser.  erg.

 

maybe i'll resort to setting the src of an iframe to my desired host if the app is running for the first time

Contributor
Posts: 21
Registered: ‎11-24-2010
My Device: Not Specified
My Carrier: T-com

Re: BB Torch and sqlite/http connection

Have you solved the problem when excute "openDatabase("myDb", "1.0", "myDb", dbSize);" will throw exception on OS 6.0?