B4A Library MySQL Library with jdbc

rg58sma

Member
Licensed User
Longtime User
Dont work for me



'write your own parameters
'a.setDatabase("server ipnumber (not name)","databasename","username","password") 'Cancel this line
'you can write named server
a.setDatabase("192.168.10.99","clientes","android","android")

' select query
L=a.Query("select * from clientes")
' or get table list for database
'L = a.TableList 'you can get all tables for default database

' CUD: Create, Update, Delete
' or UPDATE query
' Dim r as Int ' return affected rows count
' r = a.ExecuteNonQuery("update tablename set fieldname='xxxx' where keyname='xx'; ")

If L.IsInitialized=False Then
Msgbox("Records Not Found","Warning")
Return
End If
 

giga

Well-Known Member
Licensed User
Longtime User
If your settings are correct. You may want to check the manifest and make sure there is a 4 instead of 14 for the SdkVersion. I had that problem and the 14 kept giving me "Record not Found"

B4X:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4"/>

Good Luck
 

bnpmunson

Member
Licensed User
Longtime User
How to destroy/close database connection?

I did not notice any way to destroy/close the database connection. How does one go about making sure that the instance is closed and destroyed?

I need to have the database connection established/broken from within a service module that runs every 10 minutes to update a database table. I need to connect/insert/close each time I update as I don't want hundreds of always on connections to my server.
 

andre.astafieff

Member
Licensed User
Longtime User
How can I run on the android 4.0 above?
For me only returns "no records" ...

Tested on 2.3.6 and it works normally. : Confuso:
 

giga

Well-Known Member
Licensed User
Longtime User
How can I run on the android 4.0 above?
For me only returns "no records" ...

Tested on 2.3.6 and it works normally. : Confuso:

Did you check the manifiest for this... Version = 4

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4"/>
 

gokula

New Member
Licensed User
Longtime User
hello, the library works greats, but is posible to modify this part of the source? I need the source please!!

metaData.getColumnName(i) Changed to metaData.getColumnLabel(i);

(for use as headers labels the " as customfieldname" from the query)

private void addHeaders()
{
try
{
ArrayList<String> arrayHeader = new ArrayList<String>();
arrayHeader.clear();
for (int i=1;i<columnCount+1;i++)
{
String cName = metaData.getColumnLabel(i);
arrayHeader.add(cName);
}
arrayResults.add(arrayHeader);
}
catch (SQLException e)
{
return;
}
}

my email is bisognisistemas@gmail.com

thanks!!!
 

gokula

New Member
Licensed User
Longtime User
I could achieve compile the library with the modification in the code to display the alias of the field, if anyone needs the modification mail me thanks
 

frac3sco

Member
Licensed User
Longtime User
ciao ragazzi,
qualcuno posterebbe un esempio funzionate per accedere a mysql cn android 4.1.
ho provato tutti gli esempi del forum e mi restituisce l'errore che non trova i record. grazie
 

Sergio Haurat

Active Member
Licensed User
Longtime User
Dear hasanaydin52 / Erel,
What would be the correct way to pass data from a data type List to Cursor. I need to improve this version, I am using Cursor and List data types. This is very cumbersome and messy.

B4X:
Public Sub CheckTablesUpd As Boolean
  Dim blnUpd As Boolean = False
  Dim curdtSQLite As Cursor
  Dim strQuery As StringBuilder
  strQuery.Initialize
  strQuery.Append("select").Append(CRLF)
  strQuery.Append("*").Append(CRLF)
  strQuery.Append("from").Append(CRLF)
  strQuery.Append("cmn_tables_update")
  Try
    curdtSQLite = sqLiteConn.ExecQuery(strQuery.ToString)
    If curdtSQLite.RowCount = 0 Then
      Msgbox(GetRes("dbe_lUpdEmpty"), GetRes("app_name"))
      ExitApplication
    End If
  Catch
    Msgbox(GetRes("dbe_lSelect") & CRLF & LastException.Message, GetRes("app_name"))
    ExitApplication
  End Try
  Try
    Dim lstMySQL As List
    lstMySQL.Initialize
    lstMySQL = mySQLConn.Query(strQuery.ToString)
    If lstMySQL.Size = 0 Then
      Msgbox(GetRes("dbe_rUpdEmpty"), GetRes("app_name"))
      ExitApplication
    End If
  Catch
    Msgbox(GetRes("dbe_rSelect") & CRLF & LastException.Message, GetRes("app_name"))
    ExitApplication
  End Try
  Dim cntCol As Int = 0
  Dim aryData As List
  aryData = lstMySQL.Get(1)
  curdtSQLite.Position = 0
  For cntCol = 0 To curdtSQLite.ColumnCount - 1
    Dim strLocalTable, strRemoteTable As String
      strLocalTable = aryData.Get(cntCol)
      strRemoteTable = curdtSQLite.GetString2(cntCol) & ".0"
      If strLocalTable <> strRemoteTable Then
        blnUpd = True
      End If
  Next
  Return blnUpd
End Sub
 
Last edited:

keirS

Well-Known Member
Licensed User
Longtime User
Do you know you need to pay Oracle a licence fee for using the JDBC library commercially? IIRC its about 900 USD.
 

giacomo-italy

Member
Licensed User
Longtime User
Hi! Help me.
I use this library, it is my favourite, and all works fine!
But it is possible to save and load an image in blob field of mysql table, with this library? How?
Is there something like ExecuteNonQuery2 method?
Is possible to use something like Cursor? How?
Thanks!!
 
Last edited:

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Please help,
I got this error

B4X:
Parsing code.                           0.00
Compiling code.                         Error
Error parsing manifest script:
Line = 13, Word =
Command expected.

Line = 13 is:
B4X:
AddPermission("android.permission.ACCESS_NETWORK_S TATE")
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
This line looks correct. Can you post the full manifest code?

Here it is:


B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

AddPermission("android.permission.INTERNET")
AddPermission("android.permission.ACCESS_NETWORK_S TATE")
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
I tried but I've got the same problem
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…