cancel
Showing results for 
Search instead for 
Did you mean: 

Exception in DatabaseManager.createDatabase

Former Member
1,856

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

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).

Former Member
0 Kudos

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

Answers (0)