Android Question JdbcSQL / PostgreSQL Issue

Discussion in 'Android Questions' started by RichardKirk, Jul 18, 2019.

  1. RichardKirk

    RichardKirk Member Licensed User

    Have taken the example JdbcSQL Example, made changes to access PostgreSQL as I do not run MySQL.
    I built the animals table (just name and id). However, the program will not run at all.
    (using B4A 9.3)

    Changes Made to Main:
    #AdditionalJar: postgresql-42.2.6.jre7

    Changes made to Starter:
    Sub Process_Globals
    Public mysql As JdbcSQL
    Private driver As String = "org.postgresql.Driver"
    Private jdbcUrl As String = "jdbc:postgresql://"
    Private Username As String = "postgres"
    Private Password As String = "masterkey"
    End Sub

    In ListAnimals:
    Dim sf As Object = mysql.ExecQueryAsync("mysql", "SELECT id, name FROM animals WHERE id < 10", Array(300))

    The Log is very long, but the salient points to do with the connection seem to be as follows:
    --------- beginning of crash
    *** Service (starter) Create ***
    ** Service (starter) Start **
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    ** Activity (main) Pause, UserClosed = false **
    Service started in the background. Trying to start again in foreground mode.
    *** Service (starter) Create ***
    ** Service (starter) Start **
    ** Activity (main) Create, isFirst = true **
    main_activity_create (java line: 352)
    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
    at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
    at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(
    at android.database.sqlite.SQLiteDatabase.openInner(
    at android.database.sqlite.SQLiteDatabase.openDatabase(
    at android.database.sqlite.SQLiteDatabase.openDatabase(
    at anywheresoftware.b4a.sql.SQL.Initialize(
    at b4a.example.main._activity_create(
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(
    at b4a.example.main.afterFirstLayout(
    at b4a.example.main.access$000(
    at b4a.example.main$
    at android.os.Handler.handleCallback(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)
    I Make no reference to SQLite - where am I going wrong.
  2. OliverA

    OliverA Expert Licensed User

    You must have modified the example besides the information given in you initial post. According to this log, you are opening an SQLite database in Activity_Create, whereas in the example, it's just
    Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:

    End Sub
    You could have also just posted the wrong logs.

    Erel likes this.
  3. DonManfred

    DonManfred Expert Licensed User

    Please use [CODE]code here...[/CODE] tags when posting code.

  4. RichardKirk

    RichardKirk Member Licensed User

    I have no idea what was going wrong. Did a complete reinstall of B4A, Libraries.
    Downloaded JdbcSQL again, and now the example runs - still not connecting,
    but the logs make a lot more sense!
    Thank you for all your trouble!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice