B4J Question java.sql.SQLException: No Prepared Statement

jahswant

Well-Known Member
Licensed User
Longtime User
I'm trying to access and migrate one our oldest database under Paradox. The most complete JDBC for this dbis not free. I found an open source alternative but when I try with the simplest code I get the above exception. This is my code.

GIT Project

CODE:
    sql1.Initialize("com.googlecode.paradox.Driver", "jdbc:paradox:/E:/A2015_2016")
    
    Dim RS As ResultSet = sql1.ExecQuery("SELECT * FROM Paie")
    Do While RS.NextRow
        Log(RS.GetString("col1"))
    Loop
    RS.Close

FULL STACK:
main._appstart (java line: 60)
java.sql.SQLException: No Prepared Statement
    at com.googlecode.paradox.ParadoxConnection.prepareStatement(ParadoxConnection.java:517)
    at cm.jahswant.paradox.SQL.ExecQuery2(SQL.java:134)
    at b4j.example.main._appstart(main.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at b4j.example.main.start(main.java:37)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$166(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$179(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
    at java.lang.Thread.run(Thread.java:748)

Any hint will be welcomed.
 

jahswant

Well-Known Member
Licensed User
Longtime User
I just tried with JAVA Diectly Same code and it works well. What can be the issue ?

JAVA CODE:
package cm.jahswani.paratest;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ParadoxTest {

    public static void main(String[] args) throws SQLException {
        // TODO Auto-generated method stub
        
        try {
            Class.forName("com.googlecode.paradox.Driver");
            java.sql.Connection conn = DriverManager.getConnection("jdbc:paradox:/E:/A2015_2016");
            Statement stmt=conn.createStatement();
            ResultSet rs=stmt.executeQuery("select * from Paie");
            while(rs.next())
                System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)); conn.close();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        

    }

}
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The SQL library always creates a prepared statement. Apparently it is not supported by this JDBC driver.

You can call createStatement and executeQuery with JavaObject:
B4X:
Dim jo As JavaObject = sql
Dim statement As JavaObject = jo.GetFieldJO("connection").RunMethod("createStatement", null)
Dim rs As ResultSet = statement.RunMethod("executeQuery", Array("select * ..."))
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…