添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
B4X is a set of simple and powerful cross platform RAD tools:
  • B4A (free) - Android development
  • B4J (free) - Desktop and Server development
  • B4i - iOS development
  • B4R (free) - Arduino, ESP8266 and ESP32 development
  • All developers, with any skill level, are welcome to join the B4X community .

    Java Question [Java] No suitable driver found for jdbc:sqlite

    I'm building this library, but it generates an error, tells me that the drivers are missing and therefore the connection does not open because of null value.
    Something is missing.
    Public Sub Update(filenameDB As String, TableName As String,ID As Int, Field As String, fn as string)
        Dim J As JavaObject = Me
        J.RunMethod("SetDB",Array As String(filenameDB))
        J.RunMethod("update",Array As Object(TableName,Field,ID,fn))
    End Sub
    #if Java
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import anywheresoftware.b4a.BA.Permissions;
    @Permissions(values={"android.permission.WRITE_EXTERNAL_STORAGE"})
     String url = "jdbc:sqlite:C://sqlite/db/test.db";
     public void SetDB(String filename) {
         url = "jdbc:sqlite:" + filename;
         BA.Log(url);
     public Connection connect() {
            // SQLite connection string
            Connection conn = null;
            try {
                conn = DriverManager.getConnection(url); ' FIRST ERROR ---------------
            } catch (SQLException e) {
                System.out.println(e.getMessage());
                BA.Log("Errore: " + e.getMessage());
            return conn;
     public void update(String tablename, String fieldname, int materialId, String filename) {
            // update sql
            String updateSQL = "UPDATE " + tablename
                    + " SET "+ fieldname + " = ? "
                    + "WHERE ID= ?";
            try {
                BA.Log("1");
                Connection conn = connect();
                BA.Log("2: " + updateSQL);
                PreparedStatement pstmt = conn.prepareStatement(updateSQL);
               // -----------------     HERE: Crash - Conn is nul --------------------
                // set parameters
            } catch (SQLException e) {
                System.out.println(e.getMessage());
    #End If
    *** Service (starter) Create ***
    ** Service (starter) Start **
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    jdbc:sqlite:/storage/emulated/0/test.sql
    Error: No suitable driver found for jdbc:sqlite:/storage/emulated/0/test.sql
    2: UPDATE mytable SET bitmap = ? WHERE ID= ?
    sqlite_updatebitmap (B4A line: 15)
    J.RunMethod("updatePicture",Array As Object(Table
    java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at b4a.example.sqlite._updatebitmap(sqlite.java:161)
    at b4a.example.main._buttonsave1_click(main.java:482)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:6199)
    at android.widget.TextView.performClick(TextView.java:11090)
    at android.view.View$PerformClick.run(View.java:23647)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6682)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
    Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.PreparedStatement java.sql.Connection.prepareStatement(java.lang.String)' on a null object reference
    at b4a.example.sqlite.updatePicture(sqlite.java:228)
    ... 19 more P.S. I know you can avoid the LoadBitmap and SaveBitmap to pass images in byte arrays, I'll optimize the code later, now I'm trying to make it work
    Thanks, but I had already seen and does not solve the problem, but it generates me another mistake.
    Exception.getMessage() = com.mysql.jdbc.Driver
    Rather it seems that I should add jar package
    Put the sqlite driver into the Objects\bin\extra folder (in my case I have sqlite-jdbc-3.19.3.jar). I tried but without results.
    However I rewrote everything in B4A .
    In the future, if I need java, I will lose some time. I think the driver's request was wrong.
    @OliverA Thanks for your support, good return. ;) ;) ;) ;) 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. Accept Learn more…