> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.codenameone.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# 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](https://www.codenameone.com/javadoc/com/codename1/db/package-summary.html). You can read more about usage etc. in the developer guide [IO section](https://www.codenameone.com/manual/files-storage-networking.html#_sql).

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](https://www.codenameone.com/blog/connecting-to-a-mysql-database.html) uses PHP and Xatafaces as a proxy.
* The [second approach](https://www.codenameone.com/blog/connecting-to-a-mysql-database-part-2.html) uses a Java server as proxy.