Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » UltraLite - Java Programming » UltraLiteJ application development » UltraLite and UltraLite Java edition database creation and connection approaches


Creating or connecting to a database

Use the UltraLiteJ API with your Java application to create or connect to a database.


An existing Java application for an Android or a BlackBerry smartphone that implements the UltraLiteJ API.

  1. Create a new Configuration object that references the database name and is appropriate for your platform.

    In the following examples, config is the Configuration object name and DBname is the database name.

    For Android smartphones:

    ConfigFileAndroid config = 

    For BlackBerry smartphones:

    ConfigObjectStore config = 

    For Java SE platforms:

    ConfigFile config = 

    For any platform, you can create a non-persistent database Configuration object:

    ConfigNonPersistent config = 
  2. Set database properties using methods of the Configuration object.

    For example, you can set a new database password using the setPassword method:


    For Android smartphones, you can use the setCreationString and setConnectionString methods to set additional creation and connection parameters, respectively.

    For more information about creation and connection parameters, see:

  3. Create a Connection object to create or connect to the database:

    For example, the following code creates a new database:

    Connection conn = DatabaseManager.createDatabase(config);

    The DatabaseManager.createDatabase method creates the database and returns a connection to it.

    In the above example, the following code is used to connect to an existing database:

    Connection conn = DatabaseManager.connect(config);

    The connect method finalizes the database connection process. If the database does not exist, an error is thrown.


You can execute SQL statements from your Java application to create the tables and indexes in your database but you cannot change certain database creation parameters, such as the database name, password, or page size.

 See also