views:

134

answers:

2

I have a big problem using the default SQLite database via JDBC driver.I would like to use ORMLite with this.Let me expose my code:

String databaseUrl = "jdbc:sqlite:/data/data/my.package.name/db.sqlite";

            Class.forName("SQLite.JDBCDriver");
        DriverManager.getConnection(databaseUrl);

        dataSource = DatabaseTypeUtils.createSimpleDataSource(databaseUrl);
        databaseType = DatabaseTypeUtils.createDatabaseType(dataSource);
        databaseType.loadDriver();

        UpDao = new UserProfileJdbcDao(databaseType);
        UpDao.setDataSource(dataSource);
        UpDao.initialize();

I downloaded the ormlite2.8.jar (src) and modified the SqliteDatabaseType class so that the private final static String DRIVER_CLASS_NAME = "SQLite.JDBCDriver" . However when I imported all of the classes from the ormlite2.8.jar(src) , I found errors concerning the logger, specifically the CommonsLoggingLog and Log4jLog classes.Someone advised my to write my own Logger class that uses the Android logger , but I do not know how to do that. This is the ORMLite I am using for Android : http://ormlite.sourceforge.net/sqlite_java_android_orm.html

I am highly appreciating any help. Thank you in advance.

Regads, Andrew

+2  A: 

In the documentation of ORMlite is mentioned, that there are no direct dependencies and Log4J will be only used if provided in the class path.

Are you sure, that importing the complete code is the right way using ORMlite?

What about that: http://ormlite.sourceforge.net/javadoc/doc-files/ormlite_5.html#SEC25 You should do whats mentioned in the first sentence:

DatabaseType databaseType = new SqliteAndroidDatabaseType();
databaseType.loadDriver();
// change this for your path and application name
String databaseUrl = "jdbc:" + databaseType.getDriverUrlPart() + ":" + getFilesDir() + "/test.db";
SimpleDataSource dataSource = DatabaseTypeUtils.createSimpleDataSource(databaseUrl);

// configure and use your dao as in previous examples
WarrenFaith
A: 

This is an old question Andrew, but for posterity, Ormlite as of version 3.X has native support for the Android OS database calls. I'd recommend upgrading and trying it out. There are sample projects, documentation, and downloads here:

http://ormlite.sourceforge.net/sqlite_java_android_orm.html

Gray