How to use a JDBC driver different than the default SQLDroid driver with JDXA ORM?

Here are the steps to use a new non-default JDBC driver with JDXA ORM:

1- Define a class, say MyDatabaseAndJDX_Initializer, that extends the class com.softwaretree.jdxandroid.DatabaseAndJDX_Initializer

2- Override the following two methods in the class MyDatabaseAndJDX_Initializer to provide the new JDBC driver specific values:
/** * Returns the the fully expanded class name of the JDBC driver to be used by JDX ORM. * A subclass may override this method to provide a non-default JDBC driver name. * <p> * @return JDBC Driver class name */ protected String getJDBCDriverClass() { return "org.sqldroid.SQLDroidDriver"; } /** * Returns the prefix for the JDBC url as per the JDBC driver used. * A subclass may override this method to provide a non-default value. * * @return JDBC url prefix */ protected String getJDBCPrefix() { return "jdbc:sqldroid:"; }
3- In the method AppSpecificJDXSetup.initialize() of you app, add the following statement (see the sample project JDXAndroidListExample1 for an example):
setDatabaseAndJDX_InitializerClass(ormId, MyDatabaseAndJDX_Initializer.class);

4- Add the new JDBC driver code (e.g., its jar file as a library) in your project
Sign In or Register to comment.