File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes Connect MySql to Android Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Connect MySql to Android " Watch "Connect MySql to Android " New topic

Connect MySql to Android

Terence Gronowski
Ranch Hand

Joined: Dec 19, 2007
Posts: 64
I want to synchronize the internal Sqlite Database to an external MySQL Database (I work with Eclipse).

I imported mysql-connector-java-5.1.13-bin.jar into the project, but the conversion to another Format (davlink) does not succeed.

Somebody have an idea?

Docendo discimus (we learn by teaching)
SCJP 5 Zertifizierung, Vorbereitungsbuch; SCJP 6 Zertifizierung, Vorbereitungsbuch

Dave MacLean
Ranch Hand

Joined: May 10, 2011
Posts: 49

If I'm correctly understanding what you're trying to do, the problem is with "localhost". You're trying to connect to the external database from within your Android environment. Android is running Linux underneath, so you've got an operating system there, and localhost to that OS means the Android device. What your code says to do is open port 3306 on the Android device. You'll need to give the IP address of your external host to connect to it from Android.

- dave

Dave MacLean our book (Pro Android 4)
Terence Gronowski
Ranch Hand

Joined: Dec 19, 2007
Posts: 64
Dave thanks

I run It with the Emulator on the one same machine. I indeed have to specify the IP of my PC there as for Android the Emulator is "localhost". But that is not the main problem. There is an error message "Conversion to Davlink format failed with error1". I supose this is the error which is caused because the compilation fails when i should rework "mysql-connector-java-5.1.13-bin.jar" into the Davlink format.
Satya Komatineni
Ranch Hand

Joined: May 11, 2011
Posts: 38

One can certainly include externally build jar files by other java compilers in to android.

Here is a research link for this topic

Externally built jar files and Android

However you must see what other java jar files those may further depend on. Also the android java sdk is a smaller subset of the full java sdk. So if the external jar is using some classes that don't exist in android jar then they will fail.

Hope this is of some help


My Web Site:
Our Book for Tablets/Phones: Pro Android 3
I agree. Here's the link:
subject: Connect MySql to Android
It's not a secret anymore!