B4J Question JAR from AAR?

Avon

Member
Licensed User
Longtime User
I have an AAR file (sqlite-android-3180000.aar).

What do I have to do to use it with B4J, please?
 

DonManfred

Expert
Licensed User
Longtime User
Where does the file come from? URL to Documentation.
What is inside the AAR?

Probably you need to write a java library to use it.
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Wrong forum?

Both B4A and B4J support SQLite so I'm not sure why you are trying to wrap an already supported feature.
 
Upvote 0

Avon

Member
Licensed User
Longtime User
Having converted the B4A example to B4J, I'm not impressed by JDBC. So I'm still looking for a way of using SQLite's own java library as per post #1.

Not all wrappers are created equal. JDBC lends itself best to portability, which is of zero interest to me.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
If you are happy to code a bit in java (or use javaobjects) you can deal directly with the database . B4J doesn't force you to use libraries.
Simple example - just opens and then closes a database. You would need to add resultsets etc, but not too much code to do.
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar: sqlite-jdbc-3.7.2.jar ' this is in libs folder of B4J (v5.50)
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
asJO(Me).RunMethod("connect",Null)
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub asJO(o As JavaObject) As JavaObject
Return o
End Sub
#if java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public static void connect() throws ClassNotFoundException {
  Connection conn = null;
  try {
Class.forName("org.sqlite.JDBC"); // force classloader to load the sqllite driver
  // db parameters
  String url = "jdbc:sqlite:mydatabasefile.db";
  // create a connection to the database
  conn = DriverManager.getConnection(url);
 
  System.out.println("Connected");
 
  } catch (SQLException e) {
  System.out.println(e.getMessage());
  } finally {
  try {
  if (conn != null) {
  conn.close();
System.out.println("Closing database");
  }
  } catch (SQLException ex) {
  System.out.println(ex.getMessage());
  }
  }
}
#End If
 
Upvote 0

Avon

Member
Licensed User
Longtime User
Thanks Daestrum, but what I need is a way to use the methods in the sqlite-android-3180000 library. B4J does not like the format of the jar file contained therein.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I don't think you will get that aar file to work with B4J as it contains many references to android specific code, for example, toast messages that do not exist in 'desktop' Java.
I may be wrong of course (wouldn't be the first time :) )
 
Upvote 0

Avon

Member
Licensed User
Longtime User
I'm not attacking JDBC, nor do I want to put myself to the trouble of defending my methods. I just want to use something close to the API which SQLite.org publishes. Is that OK?
 
Upvote 0
Top