I had done a lot of searches about how to connect an android app to a firebird DB but still cannot do it.
First of all this is my code to create a connection:
@NonNull
public static void createConnection() throws SQLException {
if (connection == null || connection.isClosed()) {
Properties props = new Properties();
props.setProperty("user", "###");
props.setProperty("password", "####");
props.setProperty("encoding", "UTF8");
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
connection = DriverManager.getConnection("jdbc:firebirdsql://<HOST>:<PORT>/<DATABASE>.fdb", props);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
Log.e(MY_LOG_TAG, "Falhou ao criar conexão com o Banco! -> " + e.getMessage());
}
}
}
Considerations:
As saw on https://stackoverflow.com/a/57036670/4628993, JDBC Jaybird (aka. jaybird-full-4.0.0.java8.jar) does not work on Android:
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/resource/Referenceable; at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:454)
So i check the answer's link that pointed me to a Android solution: (https://sourceforge.net/projects/androidjaybird)
- Android Jaybird (last update 2017-03-30)
I downloaded the Jaybird_2_2_12.aar and clean my project. Install the *.aar as a new module (new module > aar > Jaybird_2_2_12.aar) and sync with gradle:
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Failed to transform artifact 'Jaybird_2_2_12.aar (project :Jaybird_2_2_12)' to match attributes {artifactType=android-dex, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=29, org.gradle.usage=java-runtime}. Execution failed for DexingNoClasspathTransform: /home/vapstor/Workana/RoyalFarma/Jaybird_2_2_12/build/.transforms/9b92b1a4ee0f4f8ba116c8e17cff3dd0/jetified-Jaybird_2_2_12-runtime.jar. Error while dexing.
also logs me:
Compatible side by side NDK version was not found. Default is 20.0.5594570.
EDIT:
I forgot to mention that i downloaded an project from here https://www.firebirdsql.org/en/firebird-3-0/#Android too, but it seems that is to install a firebird database on android devices, i need to access it only.