connection with sqlite does not work

I have 3 classes

first class

public class MyApp extends UiApplication {
    /**
     * Entry point for application
     *
     * @param args
     *            Command line arguments (not used)
     */
    public static void main(String[] args) {
        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        MyApp theApp = new MyApp();
        theApp.enterEventDispatcher();
    }

    /**
     * Creates a new MyApp object
     */
    public MyApp() {
        // Push a screen onto the UI stack for rendering.
        DBAdapter db=new DBAdapter();
        db.openOrCreateDatabase();
        pushScreen(new MyScreen());
    }
}

second class

public final class MyScreen extends MainScreen implements FieldChangeListener
{
    /**
     * Creates a new MyScreen object
     */
    private ButtonField addButton = new ButtonField("Add Records",
            ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER);
    private ButtonField deleteButton = new ButtonField("Delete Records",
            ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER);
    public MyScreen()
    {
        // Set the displayed title of the screen
        setTitle("MyTitle");
        HorizontalFieldManager hfm = new HorizontalFieldManager();
        addButton.setChangeListener(this);
        deleteButton.setChangeListener(this);
        hfm.add(addButton);
        hfm.add(deleteButton);
        add(hfm);
    }
    public void fieldChanged(Field field, int context) {
        // TODO Auto-generated method stub
        if (field == addButton) {
            DBAdapter db=new DBAdapter();
            db.insertTableData();
            String[] data=db.getCat();
        }
    }
}

third class

public class DBAdapter {

    private static String DB_NAME = "test.db";
    public Database db;
    public void openOrCreateDatabase() {
        boolean sdCardPresent = false;
        String root = null;
        Enumeration e = FileSystemRegistry.listRoots();
        while (e.hasMoreElements()) {
            root = (String) e.nextElement();
            if (root.equalsIgnoreCase("sdcard/")) {
                sdCardPresent = true;
            }
        }
        if (!sdCardPresent) {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    Dialog.alert("This application requires an SD card to be present. Exiting application...");
                    System.exit(0);
                }
            });
        } else {
            try {

                String dbLocation = "/SDCard/databases/";
                // Create URI
                URI uri = URI.create(dbLocation + DB_NAME);

                // Open or create a plain text database. This will create the
                // directory and file defined by the URI (if they do not already
                // exist).
                db = DatabaseFactory.openOrCreate(uri);
                createDatabaseSchema();
            } catch (Exception ae) {
                Dialog.alert("Error,database not created...");
            }
        }
    }

    private void createDatabaseSchema() {
        Statement st = null;
        try {
            st = db.createStatement("CREATE TABLE IF NOT EXISTS 'People' ( 'Name' TEXT, 'Age' INTEGER )");
            st.prepare();
            st.execute();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                st.close();
            } catch (DatabaseException e) {
            }
        }
    }

    public void insertTableData() {
        Statement st = null;
        try {
            st = db.createStatement("INSERT INTO People(Name,Age) VALUES (?,?)");
            st.prepare();
            Hashtable ht = new Hashtable(5);
            ht.put("Joe", new Integer(6));
            ht.put("Mike", new Integer(7));
            ht.put("Marie", new Integer(12));
            ht.put("Dennis", new Integer(14));
            ht.put("Richard", new Integer(12));
            Enumeration names = ht.keys();
            Enumeration ages = ht.elements();
            while (names.hasMoreElements()) {
                String strName = (String) names.nextElement();
                Integer iAge = (Integer) ages.nextElement();
                st.bind(1, strName);
                st.bind(2, iAge.intValue());
                st.execute();
                st.reset();
                Dialog.alert("ok");
            }
        } catch (Exception e) {
            Dialog.alert("Error");
        } finally {
            try {
                st.close();
            } catch (DatabaseException e) {
                Dialog.alert("Error");
            }
        }
    }

    public String[] getCat() {
        String[] data = {};
        if (db == null) {
            return data;
        }
        Statement st = null;
        try {
            st = db.createStatement("SELECT Id,Name FROM Cat");
            st.prepare();
            Cursor c = st.getCursor();
            if (c == null) {
                return data;
            }
            Row r;
            int i = 0;

            while (c.next()) {
                r = c.getRow();
                data[i] = r.getString(1);
                i++;
                // recordList.insert(0, r.getString(0) + " - " +
                // r.getInteger(1)+ " years old");
            }
            if (i == 0) {
                return data;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                st.close();
            } catch (Exception e) {
            }
        }
        return data;
    }
}

There is problem please help me

How do you define the instance "db" on the screen?

Tags: BlackBerry Developers

Similar Questions

  • My labtop sound works, but when connect the headphones does not work

    My labtop sound works, but when connect the headphones does not work. Note that the headset before 1 HR was working.

    Hello

    ·         Are these USB headset or headphone jack analog standard?

    ·         What version of the operating system is installed on the system?

    If you continue Windows 7 or Windows Vista refer to the procedure in method provided below and check if they help to resolve the issue.

    Method 1:

    Step 1:

    You can check if the headphones are activated as a playback device. To do this, see the following steps:

    (a) the Pearl-click Start and type Sound in the start search box.

    (b) in the Start Menu Options, select change adapter settings .

    (c) then, on the Read tab, right-click and select Show hidden devices and Show disconnected devices if they are available.

    (d) select headphones and select

    Step 2:

    Also try to put headphones of default device and check, follow the steps below.

    (a) go to Start and click on Panel.

    (b) click Sound, and then a new window will open.

    (c) in the new window click on the "Playback" tab and right-click in the window and click on Show disabled devices.

    (d) now check if headphone is listed there and right-click on it and choose activate.

    (e) highlight this helmet and click on "as default'.»»

  • I am trying to create a VPN connection, but it does not work

    I am trying to create a VPN connection, but it does not work
    The wizard cannot establish a connection. And if I try to record simply does not connect
    It does not work. If I try to click on find the problem, there simply
    do nothing.
    I tried it on another pc, where it worked. So the problem is not the
    router or data network. And the curious thing is that I installed it before, but only from one day to the other, the VPN connection was missing.

    It does not create even a the connection icon
    Thank you

    Try a system restore to a Date before the problem began:

    Restore point:

    http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-system-restore/

    Do Safe Mode system restore, if it is impossible to do in Normal Mode.

    Try typing F8 at startup and in the list of Boot selections, select Mode safe using ARROW top to go there > and then press ENTER.

    Try a restore of the system once, to choose a Restore Point prior to your problem...

    Click Start > programs > Accessories > system tools > system restore > choose another time > next > etc.

    http://www.windowsvistauserguide.com/system_restore.htm

    Read the above for a very good graph shows how backward more than 5 days in the System Restore Points by checking the correct box.

    See you soon.

    Mick Murphy - Microsoft partner

  • Wireless connects, but internet does not work

    My wifi signal is strong. My computer says that it is connected. Diagnosis shows the signal is stable, but when I open a browser, it does not connect. It just seems to take forever, but nothing ever happens in Safari. Chrome has said, "there no internet connection. Your computer is offline. "and that Firefox says: 'server not found '.

    I tried the Ethernet connection, but it's the same story. Computer indicates recognition signal, but it will never truly connect. It will connect in Safe Mode, however.

    I don't know if this is related, but iTunes does not work either. I open and just get the reel spinning forever. It is said he is unresponsive, and I force quit.

    Here is some information that might be useful:

    -iPhones and MacBook in the House are fine to connect to Internet.

    -My internet company just came and installed a new router/modem. We had a few problems before (this is why they came to reinstall the hardware), so I don't know if this has something to do with him or not.

    iMac

    OS X El Capitan 10.11.6

    3.2 GHz Intel Core i5

    Deselect if selected proxy.

    System Preferences > network > advanced > proxies tab

    Unlock the lock if you have to.

    Under "Select the Protocol", uncheck all box if marked cheque.

    Click 'OK' and then 'apply '.

  • wireless connected but internet does not work

    Since yesterday my laptop has had problems connecting to the internet. It will say that it is connected to the internet but yet when I open a browser or any other program requiring internet, it does not work. However, when I use the same connection from another laptop, the internet works.

    I tried to use the option diagnose & repair and he always tells me that everything is fine. I also tried to restart my laptop and check my firewall settings, which did not help either. any help would be greatly appreciated!

    Hello

    Turn off the router or the modem (unplug the power supply) - wait 3 minutes, then the power restore - restart the computer.

    If necessary:

    Two methods - I would try 1. first and use 2. only if necessary because with 2 it can come back.

    1.

    Your router could be suspicious here, you have successfully updated its firmware as a possible solution? And I would like to
    Update your WiFi drivers on computers. How you are positioned in the router? Are there
    obstacles in the path?

    Actually try updating your driver and disabling the network logon. If you usually use WiFi try a wire
    and if you usually use a wire try WiFi. Update, one being not used 1.

    Control Panel - network - write down of the brand and the model of the Wifi - double click top - tab of the driver - write
    version - click the driver update (cannot do something that MS is far behind the pilots of certification). Then
    Right click on the Wifi device and UNINSTALL - Reboot - it will refresh the driver stack.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    How to install a device driver in Vista Device Manager
    http://www.Vistax64.com/tutorials/193584-Device-Manager-install-driver.html

    Download - SAVE - go where you put it - right click – RUN AS ADMIN.

    You can download several at once however restart after the installation of each of them.

    After watching the system manufacturer, you can check the manufacturer of the device an even newer version. (The
    manufacturer of system become your backup policies).

    Repeat for card (NIC) network and is a good time to get the other updated drivers as Vista like
    updated drivers.

    I would also turn off auto update for the drivers. If the updates Windows suggests a just HIDE as they
    are almost always old, and you can search drivers manually as needed.

    How to disable automatic driver Installation in Windows Vista - drivers
    http://www.AddictiveTips.com/Windows-Tips/how-to-disable-automatic-driver-installation-in-Windows-Vista/
    http://TechNet.Microsoft.com/en-us/library/cc730606 (WS.10) .aspx

    ------------------------------------------------------

    Make sure you know the details of connection to your router wireless and wired - SSID and password.

    You lose connection when you do and have to redo your logon.

    Control Panel - Network & Sharing Center - right, click Customize - page set of network locations.
    lower left click on merge or delete network locations - REMOVE all instances of your network (and the
    others you don't use anymore) - REBOOT. Start - Connect To log on to the network.

    -----------------------------------------------------

    Check this box:

    Strange problem with Internet under Vista
    http://www.catonett.com/blog/archives/194

    Windows Vista cannot obtain an IP address from certain routers or some non-Microsoft DHCP servers
    http://support.Microsoft.com/kb/928233/en-us

    ----------------------------------------------------

    And:

    Network connection problems
    http://windowshelp.Microsoft.com/Windows/en-us/help/33307acf-0698-41ba-B014-ea0a2eb8d0a81033.mspx

    ==============================================

    2.

    Do a system restore before it happened.

    How to make a Vista system restore
    http://www.Vistax64.com/tutorials/76905-System-Restore-how.html
    I hope this helps. Rob - bicycle - Mark Twain said it is good.

  • Auto unlock with Sierra does not work

    Ive got everything turn on; two factor security, have my bluetooth turned on, to have a password on my watch, ect. When I turn on my laptop it says "Unlock with Apple Watch", but then makes me want to use the access code. Ive tried everything, reboot, reboot shows, ect.

    his cause, if it wasn't, it wouldn't show me 'release with Apple Watch ', so I know his shot, but for some reason, its does not work. Maybe a small problem?

    Check that you meet the requirements of the system

    Automatically unlock your Mac with your Apple Watch - Apple Support

  • The "Open with" function does not work.

    'Open with... '. "does not work. I have Win 7. Usually when I have a new type of file can I associate a program with this extension, but recently I am unable to do so. I have a midi file normal (extension .mid) and I try to associate a program with it with the function "open with...". ", I choose the program from the list, but after that the function"open with... ". "forget my selection. I looked at regedit, to try to solve the problem, but I could not understand what I have to change.

    Here are a few topics for you at checkout.

    Problem with the menu 'Open with' - Microsoft Answers:
    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-windows_programs/problem-with-open-with-menu/76b17b64-2Fe3-4c08-ac80-0ba80334dd8e

    Cannot select the program in 'open with... '. "- Microsoft Answers:
    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-files/cannot-select-program-in-open-with/860fe524-4803-4c94-8ca7-7eac2649356c

    Can't 'open with... '. ', or define associations of files - Microsoft Answers:
    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-windows_programs/cant-open-with-or-set-file-associations/d9452df6-c2c7-462e-B2ca-646f0ea782bd

  • Panel request ADF with Table does not work

    I am simple search.jsf of JSF page. In the search.jsf , I have an ADF search form. I drag and drop the view criteria into the Panel Query ADF with Table. The user search result will be displayed in a table ADF. The View object is simple no LOVs no variable binding even no where clause.



    Everything works fine if I run the page separately not with in the workflow. But if I turn the page with in a workflow, the search engine does not work.

    The workflow structure is simple, it has towed home.jsf and search.jsf pages and there is a control of navigation of the home page to the Search page. The problem is that the search engine is not work IE when I press the default search key that doesn't come with the form no coming on the data table.,.


    I use Jdeveloper with ADF technology 11.1.2.3

    My God, what a ridiculous and foolish.

    Partial trigger is missing.

    I have to add the id of the request to the partial trigger on the table. I thought that his coming by default to search forum.

    What a waste of time...

  • Satellite L350 - 146 PSLD0E - common modul with XP does not work

    My problem is exactly the same as Gigels, except my Toshiba is not model Canadian but TOSHIBA EUROPE GMBH.

    My Toshiba is
    L350-146
    PSLD0E-00V00TF3

    The diver of common Modules does not work.
    How it does not work is because when I try to install Toshiba controls it tells me that "TOSHIBA common Modules is not installed on your computer. I can go on, but it does not (obviously). I've tried versions 1.00.05, 1.00.08 (both of which are on the European driver from Toshiba site) and none of them work.
    After you have installed one of them I get this message from PowerSaver: 'TOSHIBA common Modules does not run correctly. You can use TOSHIBA Power Saver. »

    * Please help me, it is obvious that a lot of people have same problem.*

    Hello

    If so many people have the same problem, I wonder why your assignment is almost 5 days without any comment about it.

    In any case, I put t know what is the problem but the fact is that all the drivers, tools and utilities must be installed in a specific order.

    After installing Windows XP SP2 home edition, you must install stuff like this:
    WINDOWS XP HOME SP2
    Driver Chipset
    Display driver
    Audio driver
    Driver modem
    Flash media driver
    Common modules
    LAN driver
    Touchpad driver
    Enabling/disabling the touchpad utility

    And so on.

    Common modules must be installed before you install any other Toshiba tool or utility. Common modules is something as a basis for all other tools and utilities.

    Energy-saving install almost to the end.

  • Send signed with password does not work

    I'm trying to password protect some PDF files then use to send to the signature.

    I get an error of unsupported file type.

    It is a PDF. I added the Adobe password right.

    Help, please!

    I bought this so I could easily send things for signatures.

    It does not work if you add a password?

    I have to do something special to send protected Word files?

    Hi cynthiab17320112 , billa820241 & rd522,

    Please check the help below link:

    - How to encrypt your documents using Adobe sign

    Kind regards

    Nicos

  • I try to click on 'connect', this option does not work.

    Hello

    I tried to download a free trial version for Adobe photoshop and the option "Log" for it does not work on my desktop. What I would do in this regard?

    Thank you.

    Debopreeti Mukherjee

    Please run the vacuum cleaner to remove traces of CC and Adobe Application Manager, and then reinstall it again.

    1. remove the cloud creative app.

    2. install Creative Cloud app - https://helpx.adobe.com/creative-cloud/help/install-apps.html

    Let us know if you use the cleanup tool and remove Cloud Creative & AAM.

  • Download error - button charger works with applications does not work

    The "reload applications" button does not work. But under the tabs "Home" 'Assets', 'Community' everything works beautifully.

    What do I do?

    Capture-d’écran-2015-05-21-à-08.39.51.jpg

    Hi Serge,

    Please check the help below document:

    Download error in the applications tab of Creative Cloud Desktop Application

    You can also view the nets below where this issue has been addressed:

    https://forums.Adobe.com/thread/1156604

    Re: Creative Cloud "Download error" message

    Kind regards

    Sheena

  • Simple drag & drop with Manager does not work in Edge?

    Hi all!

    I made this very simple example drag-and - drop on board: http://www.terredainventare.it/simpledrag/simpledrag.html using Jquery Ui http://docs.jQuery.com/UI/draggable .

    I try to use the property of "handle" JQueryUi which makes you drag an object restricting drag by clicking on a single element, but it does not work.

    Here is the code that I put in onCompositionReady edge:

    SYM. $("drag") .draggable ({handle: "handler"});

    Of course, my two Div elements are called "drag" and "Manager". Now the brake only works on element 'wrong' and not on the 'handle '...

    Here are the files Adobe Edge: http://www.terredainventare.it/simpledrag/Web.zip

    Thank you very much in advance for your help!

    Davide

    OK Joel, I solved it!

    The handle-div must be nested in the drag-dive to make it works!

    Here is the picture:

    Thanks a lot for your help!

    Davide

  • Flash Player 10 seems uncompatable with everything - does not work

    Please forgive me if I would have found my answer elsewhere but I searched the internet for a week including on the adobe site before trying this approach.

    My computer has of worked until last week when I allowed a Flash Player update - now nothing requires the work of flashplayer.

    I have a 1 year HP Compaq AMD Semeron 2.00 GB CQ5300y (1, 87Free) 64-bit operating system.  As I assertained Flash Player does not work in 64-bit I opened and downloaded 32 bit IE I can probably do it in my sleep.  I installed and used the uninstall tool and restarted both after you uninstall and then reinstall.  Yet when I click on a clip (youtube) or a link in an e-mail message, I got a popup that says I have to install the latest version of the player.

    I looked into installed programs and only see acrobat and reader 9.  Crontrol Panel configuration/programs I find the active x 10 Flash, adobe AIR, Adobe shockwave and DL Manager

    On IE, tools | Add - ons, you see Shockwave Flash object, and it is enabled?

  • computer starts but nothing works. OneCare has been stopped, restart, no network connection found, office does not work. Analysis now with the malicious software removal tool, but nothing happens.

    OneCare was 'arrested' will not restart
    Wireless networks - does not and cannot correct
    No program will run if I'm in safe mode
    I did a virus scan with the malicious software removal tool, nothing was found.
    I write this on my netbook - I can't have my laptop online.
    I have no idea what to try next.  I need my laptop!  Help, please

    Hello laughingpaws,

    To help resolve this issue, use the System File Checker (SFC.exe) tool to determine which file is causing the problem and then replace the file. To do this, follow these steps:

    1. Open an elevated command prompt. To do this, click Start, click principally made programs, Accessories, right-click guest, and then click run as administrator. If you are prompted for an administrator password or a confirmation, type the password, or click allow.
    2. Type the following command and press ENTER: sfc/scannow sfc/scannow command analyzes all protected system files and replaces incorrect versions with appropriate Microsoft versions.

    Hope this helps you. Let us know anyway. Make it a great day!

    "And in the end the love you take, is equal to The Love You Make" (The Beatles last song from their latest album, Abbey Road.)

Maybe you are looking for

  • Bootcamp backup something again?

    How to back up the partition Windows Bootcamp with Winclone 10 when I run Windows 10 is a little PITA bread, and I hope that he has developed a way to support when running OS X 10.11.4 utility disk and time machine still will not work on the partitio

  • How can I install WXP on Equium A100?

    OK, I have an Equium A100, with Vista, but for me this OS is not good enough. I need to change for Windows XP Home edition.Who can help me?

  • Retina of MacBook Pro battery SUPER fast, please help?

    I have a MacBook Pro (retina, 13 inches, beginning 2013) and recently the fan was spinning VERY fast and I did reset smc, cleared up a bit on my laptop and now its good but the battery has fallen like a madman. It was 50% in the evening and I put sta

  • CVS1458RT, EtherCAT 9144, Softmotion

    Hello I just wanted to confirm. I want to use a 9263 analog output and a diff 9411 channel installed on a chassis of 9144 EtherCAT. I want then to use a CVS 1458RT and loop Softmotion RT to control those. (similar to the example: Interface for servom

  • change the front panel

    How can we change to frontpanel in labview? I wrote a program where the appearance of the façade must be different. How do you make different frontpanels in the face? What about Michael