Android 上的 SQLite 挂起

发布于 2024-12-29 18:04:06 字数 1786 浏览 1 评论 0原文

我不太明白这个问题,但它似乎与正在运行的 SELECT 查询相关。如果我将该查询及其关联的逻辑块注释掉(如下所示),则代码运行良好,但我在内存中没有得到所需的任何值。如果我取消注释,我会收到一百万个错误,就像这个丑陋的家伙:

D/dalvikvm(  556): GC_CONCURRENT freed 410K, 51% free 3172K/6407K, external 716K/1316K, paused 4ms+3ms

想法?

var SESSION = {
    i_company: '',
    s_username: ''
};

btn_signin.addEventListener('click', function(e) {
    btn_signin.title = 'Validating';

    var http = Titanium.Network.createHTTPClient();
    http.open('GET', VALIDATE_CREDENTIALS_URL);
    http.send({
        s_username: txt_username.value,
        s_password: txt_password.value
    });

    http.onerror = function() {
        alert('Unable to verify your credentials.');
    };

    http.onload = function() {
        var response = JSON.parse(this.responseText);

        if( response.s_status !== 'success' ) {
            btn_signin.title = 'Sign In';
            alert(response.data);
            return false;
        }

        btn_signin.title = 'Validated';

        // Store session
        var db = Titanium.Database.open('database');
        db.execute('DELETE FROM sessions');
        db.execute('INSERT INTO sessions (i_company, s_username) VALUES (?, ?)', response.data.i_company, response.data.s_username);

        btn_signin.title = 'Saving Session';

        // var db_rows = db.execute('SELECT i_company, s_username FROM sessions LIMIT 1');

        // while( db_rows.isValidRow() ) {
        //  SESSION.i_company = db_rows.fieldByName('i_company');
        //  SESSION.s_username = db_rows.fieldByName('s_username');
        // }
        db_rows.close();
        db.close();

        btn_signin.title = 'Loading App';

        // Focus on entry window
        tbg_app.open();
        wnd_signin.hide();
    };
});

I don't quite understand the issue, but it appears to be associated with the SELECT query being run. If I leave that query and its associated block of logic commented out (as shown below), the code runs fine, but I get none of the values I need in memory. If I uncomment it, I get a million errors like this ugly guy:

D/dalvikvm(  556): GC_CONCURRENT freed 410K, 51% free 3172K/6407K, external 716K/1316K, paused 4ms+3ms

Thoughts?

var SESSION = {
    i_company: '',
    s_username: ''
};

btn_signin.addEventListener('click', function(e) {
    btn_signin.title = 'Validating';

    var http = Titanium.Network.createHTTPClient();
    http.open('GET', VALIDATE_CREDENTIALS_URL);
    http.send({
        s_username: txt_username.value,
        s_password: txt_password.value
    });

    http.onerror = function() {
        alert('Unable to verify your credentials.');
    };

    http.onload = function() {
        var response = JSON.parse(this.responseText);

        if( response.s_status !== 'success' ) {
            btn_signin.title = 'Sign In';
            alert(response.data);
            return false;
        }

        btn_signin.title = 'Validated';

        // Store session
        var db = Titanium.Database.open('database');
        db.execute('DELETE FROM sessions');
        db.execute('INSERT INTO sessions (i_company, s_username) VALUES (?, ?)', response.data.i_company, response.data.s_username);

        btn_signin.title = 'Saving Session';

        // var db_rows = db.execute('SELECT i_company, s_username FROM sessions LIMIT 1');

        // while( db_rows.isValidRow() ) {
        //  SESSION.i_company = db_rows.fieldByName('i_company');
        //  SESSION.s_username = db_rows.fieldByName('s_username');
        // }
        db_rows.close();
        db.close();

        btn_signin.title = 'Loading App';

        // Focus on entry window
        tbg_app.open();
        wnd_signin.hide();
    };
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮烟 2025-01-05 18:04:06

将整个块放入 try{} 和 catch(Throwable e) 中。在调试器中逐步执行该块。找到异常发生的行。查看 catch 块中的 e。至于编程 - 您没有检查 db_rows 是否为空!这里是一个错误

Put the whole block into try{} and catch(Throwable e). Go the block step by step in debugger. Find the line where the exception rises. Look at e in catch block. As for programming - you are not checking db_rows for being null! It is an error here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文