[chargeable] MSMySQL - Yet another MySQL-Library (but a FAST one :-))

aidymp

Well-Known Member
Licensed User
Longtime User
You can...
But already if you put your password / user / etc. in Process_Global and compile in obfuscated mode also if you have ( reverse ) source in java you have this result:

B4X:
public class main
  extends Activity
  implements B4AActivity
{
  public static boolean _v7 = false;
  public static String _vv2;
  public static String _vv3;
  public static String _vv4;
  public static String _vv5;
  static boolean afterFirstLayout = false;
  public static final boolean fullScreen = false;
  public static final boolean includeTitle = true;
  static boolean isFirst = true;
  public static main mostCurrent;
  public static WeakReference<Activity> previousOne;
  public static BA processBA;
  private static boolean processGlobalsRun = false;
  public Common __c = null;
  ActivityWrapper _activity;
  public ButtonWrapper _button1 = null;
  public Map _v0 = null;
  public UltimateListViewWrapper _v6 = null;
  public MySQL _vv1 = null;
  BA activityBA;
  BALayout layout;
  ArrayList<B4AMenuItem> menuItems;
  private Boolean onKeySubExist = null;
  private Boolean onKeyUpSubExist = null;

  static
  {
    _vv2 = "";
    _vv5 = "";
    _vv4 = "";
    _vv3 = "";
  }

  public static String _activity_create(boolean paramBoolean)
    throws Exception
  {
    mostCurrent._activity.LoadLayout("Main", mostCurrent.activityBA);
    _v5();
    if (paramBoolean)
    {
      mostCurrent._v6.Initialize(mostCurrent.activityBA, (byte)0, 0, "", "ULV");
      UltimateListViewWrapper localUltimateListViewWrapper1 = mostCurrent._v6;
      BA localBA = mostCurrent.activityBA;
      UltimateListViewWrapper localUltimateListViewWrapper2 = mostCurrent._v6;
      localUltimateListViewWrapper1.SetStyle(localBA, (byte)3);
      _v7 = true;
      mostCurrent._v0.Initialize();
    }
    mostCurrent._vv1.Initialize(processBA, "MySQL", _vv2, _vv3, _vv4, _vv5);
    return "";
  }
.....

Hi MarcoRome,

So if I define the server, database, username and password in Process_Global and obfuscate the details are hidden if they decompile??

Thanks

Aidy
 

DonManfred

Expert
Licensed User
Longtime User
so does it still stand that you shouldn't use this in released apps?
Yes
if so cant you encrypt the password or similar?
It will not help at all... The app is compiled into a apk and CAN be recompiled with the right tools. even if you encrypt the password; the code to decrypt must be part of the app too. Therefor it will be easy to decrypt the password. Obfuscation does make this all a bit harder but not impossible.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi MarcoRome,

So if I define the server, database, username and password in Process_Global and obfuscate the details are hidden if they decompile??

Thanks

Aidy
Yes as you see in previous post, this is code decompilated in java.. But of course all is possible..if hacker professional.
 

aidymp

Well-Known Member
Licensed User
Longtime User
Forgive me but Database's SQL & PHP are all very new to me (I am just using tutorials on this forum and have no background knowledge at all)

So using the PHP solution can people just look at your php file and get the database info anyway??

I know nothing is impossible, but would they have to be very determined, or is it an easy task?

would it be fair to say, that using a combination of this library and PHP - using two or more databases, one containing basic app details nothing confidential and one with customer details accessed through PHP be safer??

Sorry if my questions are silly, but my app, will sort of be similar to app/playstore (Not as advanced) but contain similar details app, dev, price, images, and then a way to purchase so customer details, etc.

Thanks

Aidy
 

MarcoRome

Expert
Licensed User
Longtime User
I know nothing is impossible, but would they have to be very determined, or is it an easy task?

Easy i dont think if the code is obfuscated

would it be fair to say, that using a combination of this library and PHP - using two or more databases, one containing basic app details nothing confidential and one with customer details accessed through PHP be safer??

Nothing is sure... because anyway your pw, user, etc you must write in one place.

anyway example if you need this and you example utilize MySql is possibile create "views" from two or more databases.
 

DonManfred

Expert
Licensed User
Longtime User
So using the PHP solution can people just look at your php file and get the database info anyway??
No. php is much more save. @Erel RDC is, i personally think, the best solution but sadly i´m not allowed to run a rdc on our server. So i needed to find another solution. It started with using php and ended in coding the MySQL Libraries.
but would they have to be very determined, or is it an easy task?
It depends on their professionalism i think. FOR ME it would be no problem.
would it be fair to say, that using a combination of this library and PHP - using two or more databases, one containing basic app details nothing confidential and one with customer details accessed through PHP be safer??
probably, yes.

You also can consider to create the server part with b4j. No pw needed in your app. The b4j app is doing the query to the database and sending the results back to your app.
 

aidymp

Well-Known Member
Licensed User
Longtime User
No. php is much more save. @Erel RDC is, i personally think, the best solution but sadly i´m not allowed to run a rdc on our server. So i needed to find another solution. It started with using php and ended in coding the MySQL Libraries.

It depends on their professionalism i think. FOR ME it would be no problem.

probably, yes.

You also can consider to create the server part with b4j. No pw needed in your app. The b4j app is doing the query to the database and sending the results back to your app.

I was looking at the B4J server as I already use B4J to issue codes for purchases by email, So its always on and running. Maybe a combination would be a good solution, Once I can work out what fields to put in what table and where! ;)

Thanks

Aidy
 

adastra

Member
Licensed User
Longtime User
hi i am using your library and getting error

actcatagory_globals (B4A line: 98)
End Sub
java.lang.VerifyError: de.donmanfred.b4a.MySQL
at b4a.example.actcatagory._globals(actcatagory.java:466)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at b4a.example.actcatagory.initializeGlobals(actcatagory.java:306)
at b4a.example.actcatagory.afterFirstLayout(actcatagory.java:97)
at b4a.example.actcatagory.access$100(actcatagory.java:17)
at b4a.example.actcatagory$WaitForLayout.run(actcatagory.java:78)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
 

aklisiewicz

Active Member
Licensed User
Longtime User
OK, I have donated to this library already once but it was about 2 years ago. In the meantime I had to reinstall B4A + all libs as my PC crashed. Do I need to pay everytime I download this LIB ?

ARTHUR
 

DonManfred

Expert
Licensed User
Longtime User

adastra

Member
Licensed User
Longtime User
hi i am using your library and getting error

actcatagory_globals (B4A line: 98)
End Sub
java.lang.VerifyError: de.donmanfred.b4a.MySQL
at b4a.example.actcatagory._globals(actcatagory.java:466)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at b4a.example.actcatagory.initializeGlobals(actcatagory.java:306)
at b4a.example.actcatagory.afterFirstLayout(actcatagory.java:97)
at b4a.example.actcatagory.access$100(actcatagory.java:17)
at b4a.example.actcatagory$WaitForLayout.run(actcatagory.java:78)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
 

DonManfred

Expert
Licensed User
Longtime User
I cannot say anything about this. Don´t know what the problem is.
But i also cannot say about it; i dont know your code. I dont know the b4a version you are using. I dont know anything about your configuration, your java sdk.

so in fact it is hard to give any concrete advices
 

aklisiewicz

Active Member
Licensed User
Longtime User
Really? Then you have paid for it two years before it was released.

DonManfred, Jan 22, 2015 <--- Releasedate of this Library


No. When you have registered you got an email from me with downloadlink. The link in this email is still available.
OK, perhaps I have confused this LIB with another one. I have not used B4A for a while....
are there any example Apps that I can run to see your lib in action ?
Arthur
 

DonManfred

Expert
Licensed User
Longtime User
are there any example Apps that I can run to see your lib in action ?
https://www.dropbox.com/s/li0cu8nwjl51lsy/MySQL_Northwind.apk?dl=0

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
  Dim db As MySQL
    Private lv1 As ListView
    Private lv2 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Main")
    '             Event  Database Host          Username   Password           Databasename
    'db.Initialize("sql","host.com","dbuser","dbpassword","database")
   
    ' Manfred
    db.Initialize("MySQL","host","user","pw","db")

End Sub
Sub Activity_Resume
    Log("Activity_Resume()")
    lv1.Clear
    lv1.AddSingleLine2("Categories","Categories")
    lv1.AddSingleLine2("Employees","Employees")
   
    'Dim batch As List   
    'batch.Initialize
    For i=1 To 10
        'batch.Add("INSERT INTO b4alog SET log_value='Test"&i&"', log_time="&DateTime.Now&";")
    Next   
    'db.ExecuteBatchASync(batch,"")
    'db.ExecuteASync("INSERT INTO b4alog SET log_value='only one query', log_time="&DateTime.Now&";")   
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub MySQL_ExecResult(meta As Map)
    Log(meta)   
End Sub
Sub MySQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int)
    Log($"MySQL_Status(${Connected},${ReConnecting},${RetriesLeft})"$)
End Sub

Sub MySQL_BatchResult(batch As Map)
    Log("MySQL_BatchResult()")
    Log("Time: "&batch.Get("ms")&"ms")
    Log("Size: "&batch.Get("size"))
    Dim res As List
    res.Initialize2(Regex.Split(",",batch.Get("results")))
    Log("Results: "&res.Size)
    For i=0 To res.Size-1
        Log(i&"="&res.Get(i))
    Next   

    ' (MyMap) {ms=316, size=10, results=(ArrayList) [1, 1, 1, 1, 1, 1]}
    Log(batch)   
End Sub
Sub MySQL_QueryResult2(data As List, meta As Map)
    'Dim m As Map = meta
    Log("MySQL_QueryResult2(Columns "&meta.get("ColumnCount") _
    &", Records "&meta.Get("RecordCount")&","&meta.Get("ms")&"ms)")
    Log("Records: "&data.Size)
    For i=0 To data.Size-1
        Log(data.Get(i))
    Next   
End Sub

Sub MySQL_QueryResult(data As List, meta As Map)
    'MySQL_QueryResult2((MyMap) {ColumnCount=3, RecordCount=5, ms=32})
    Log("MySQL_QueryResult(Columns "&meta.get("ColumnCount")&", Records " _
    &meta.Get("RecordCount")&","&meta.Get("ms")&"ms,"&meta.Get("TaskID"))
    ToastMessageShow("MySQL retrieved "&meta.Get("RecordCount")&" records in "&meta.Get("ms")&"ms",True)
    lv2.Clear
    For i=0 To data.Size-1
        If meta.Get("TaskID") = "Categories" Then
            Dim cur As Map = data.Get(i)
            Dim bmp As Bitmap
            Dim In1 As InputStream
          Dim buffer() As Byte           
            buffer = cur.Get("Picture")
            In1.InitializeFromBytesArray(buffer,0,buffer.Length)
            bmp.Initialize2(In1)           
            lv2.AddTwoLinesAndBitmap(cur.Get("Description"),cur.Get("CategoryName"),bmp)
            'Log("r:"&data.Get(i))
        Else If meta.Get("TaskID") = "Employees" Then
            Dim cur As Map = data.Get(i)
            Dim bmp As Bitmap
            Dim In1 As InputStream
          Dim buffer() As Byte           
            buffer = cur.Get("Photo")
            In1.InitializeFromBytesArray(buffer,0,buffer.Length)
            bmp.Initialize2(In1)           
            lv2.AddTwoLinesAndBitmap(cur.Get("FirstName")&" "&cur.Get("LastName"),cur.Get("Title"),bmp)
            'Log("r:"&data.Get(i))
        Else
            'Log("r:"&data.Get(i))
        End If
    Next   
End Sub
Sub MySQL_ListTables(tables As List, ms As Long)
    Log("MySQL_ListTables("&ms&"ms)")
    For i=0 To tables.Size-1
        'Log("Table "&tables.Get(i))
    Next
End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)
    Dim t As String = Value
    db.QueryASync("select * from "&t&";",t)
End Sub
 
Top