How to Connect to A database? MySQL, Postgress, SQLite etc.

Codename One lets you use the "on device" sqlite database directly through the Database API. You can read about the database API in the JavaDocs here. You can read more about usage etc. in the developer guide IO section.

You can't and shouldn't connect to a remote database from a device. This is both insecure and unreliable as mobile devices don't have a reliable internet connection. If you want to access a database such as MySQL, Postgress, Oracle etc. you would need to connect to a server process that will access the data for you.

Here are two articles on the subject. Notice that these articles discuss MySQL but would work with any database:

The first approach uses PHP and Xatafaces as a proxy.
The second approach uses a Java server as proxy.

Updated on: 11/25/2022

Was this article helpful?

Share your feedback


Thank you!