Hi All,

I need some help figuring out an issue that I just can't resolve. I'm trying to create a very simple application that uses the UltraLiteJ database/api in an Android 2.2 application. I'm getting an exception when I try to create the database (code and screenshots to follow). The Android sample app works fine, but I just can't figure out where I'm going wrong.

Here is the code (full):

package net.primarysolutions.dbtest;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import com.ianywhere.ultralitejni12.ConfigPersistent;
import com.ianywhere.ultralitejni12.Connection;
import com.ianywhere.ultralitejni12.DatabaseManager;
import com.ianywhere.ultralitejni12.PreparedStatement;
import com.ianywhere.ultralitejni12.ULjException;

public class DBTestActivity extends Activity {

private ConfigPersistent m_config;
private Connection m_conn;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

    try
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        createDatabase();
    }
    catch (ULjException e)
    {
        Log.e("STUFF", e.getMessage());
    }
}

private void createDatabase() throws ULjException
{
    String db_name = "gkanywhere.udb";

    m_config = DatabaseManager.createConfigurationFileAndroid(db_name, this.getApplicationContext());

    m_config.setLazyLoadIndexes(true);

    m_conn = DatabaseManager.createDatabase( m_config );

    m_conn = DatabaseManager.connect( m_config );

    createModules();
}

void createModules()
        throws ULjException
    {
        String sql = "CREATE TABLE Modules (" +
                "Module_Name VARCHAR(30) NOT NULL, " +
                "Install_Date DATE NULL, " +
                "License_Expiration DATE NULL, " +
                "License_Limit INTEGER NULL, " +
                "Version VARCHAR(20) NULL, " +
                "PRIMARY KEY ( Module_Name ASC ))";
        executeDDL(sql);

    }

private void executeDDL(String sql) throws ULjException 
    {
    PreparedStatement ps = m_conn.prepareStatement(sql);
    ps.execute();
    ps.close();
    }
}

The exception is:

Tag = dalvikvm
Text = Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lcom/ianywhere/ultralitejni12/implementation/JniDbMgr;.<clinit>

The app wants me to force close at this point when I test against Android 2.2.

I had logging lines in and could tell that it bombs on the line:

m_conn = DatabaseManager.createDatabase( m_config );

I just can't figure out what I'm missing - any help would be greatly appreciated!

Thanks, Calvin

asked 03 Jan '12, 08:22

Calvin%20Allen's gravatar image

Calvin Allen
1.5k232638
accept rate: 25%

edited 03 Jan '12, 08:23


Calvin,

You need to copy the native library libultralitej12.so (and libmlcrsa12.so if you are using https) to libs\armeabi in your Eclipse project. From there it will get deployed to your device filesystem so that your application can load it. It is needed by UltraLiteJNI12.jar.

FYI - You don't need to call DatabaseManager.connect() after getting a connection with DatabaseManager.createDatabase(). Also, ConfigPersistent.setLazyLoadIndexes() has no effect on Android platforms (it only has an effect on Blackberry).

permanent link

answered 03 Jan '12, 09:44

Andy%20Quick's gravatar image

Andy Quick
2.2k2737
accept rate: 45%

edited 03 Jan '12, 09:44

Thank you! That's exactly what I was missing - I knew it had to be something simple!

(03 Jan '12, 10:03) Calvin Allen
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×77
×67

question asked: 03 Jan '12, 08:22

question was seen: 952 times

last updated: 03 Jan '12, 10:03