Android Question incompatibility sql and mysql library

rkxo

Active Member
Licensed User
Longtime User
Hi,
I have problems when trying to connect 2 concurrent databases . MySQL and SQLite . Attached is an example .
http://www.mediafire.com/download/qoqed7783w8btso/GestApp.rar

I get this error:



--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 65 (Main)
java.lang.ClassCastException: com.mysql.jdbc.JDBC4ResultSet cannot be cast to android.database.Cursor
at anywheresoftware.b4a.sql.SQL$CursorWrapper.getRowCount(SQL.java:313)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
at b4a.example.main._connect(main.java:403)
at b4a.example.main._activity_create(main.java:395)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)



Thank you very much for your help.
 
Last edited:

Widget

Well-Known Member
Licensed User
Longtime User
There are several libraries available to access MySQL. Do a forum search on "mysql library" and look at the examples. There are new MySQL libraries coming up every few months, including several for MariaDB which gets around licensing issues with MySQL.
 
Upvote 0

rkxo

Active Member
Licensed User
Longtime User
Then , its possible works with these libraries at the same time, sql.jar and mysql.jar?
I know that there are a lot of mysql libraries, in particular msmysql library , from mamfred. i have it,and i use it for blob data with mysql, but is more complicated for obtain fast qyeries. With mysql.jar library es very fast for programing and obtain the data. I want work with mysql.jar library becouse the app its done ,if i have change at other mysql library i have to reprograming a big code. There are any other sqlite library for b4a?. I search but i don' t found.Sorry for my english.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

rkxo

Active Member
Licensed User
Longtime User
sorry, Manfred, Which is the correct sintax of mysql?
basically i understand that:
Sub SqliteConnection
dim Sqlite as Sql 'SQL.jar library
dim SqCursor as Cursor
Sqlite.Initialize(File.DirDefaultExternal, "test.db",False)
Cursor1= Sqlite.ExecQuery("SELECT * FROM configSqlite")
For i=1 to Cursor1.RowCount-1
Cursor1.Position=i
Next
End Sub
----------------------------------------------------------
Sub MysqlConnection
dim Mysql as MysqlHandler 'mysql.jar library
dim MysqResult as ResultSet
MysqResult = Mysql.Query("SELECT * FROM configmysql")
For i=1 to MysqResult.RowCount-1
MysqResult.Position=i
Next
End sub
but resultset is assigned to sqlite engine in MysqlConnection?
----------------------------------------------------------
dim Msmysql as MySql 'msmysql.jar library
.........
.......



thanks
 
Upvote 0

rkxo

Active Member
Licensed User
Longtime User
ok, i try to find to
@BA.ShortName("MysqlHandler")
@BA.Author("Fabio Pignoletto")
@BA.Version(1.02F)

thanks
 
Upvote 0

rkxo

Active Member
Licensed User
Longtime User
yes, when i try only mysql.jar all works fine, but i load sql.jar library, gets error
Error occurred on line: 65 (Main)
java.lang.ClassCastException: com.mysql.jdbc.JDBC4ResultSet cannot be cast to android.database.Cursor


part of code mysql.jar class.

public int RowCount()
throws SQLException
{
int position = ((ResultSet)getObject()).getRow();
((ResultSet)getObject()).last();
int rowCount = ((ResultSet)getObject()).getRow();
if (position > 0) {
((ResultSet)getObject()).absolute(position);
}
return rowCount;
}
 
Upvote 0

rkxo

Active Member
Licensed User
Longtime User
its a call at MysqResult.RowCount . I think that the problem is shared one resultset or cursor in two library, its possible?

Really the question its . why when i util mysql.jar library all works fine but when i "only" load sql.jar and call anything at function of resultset or cursor gets error ?
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…