Child pages
  • Managing Database Connections

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Stoc

Overview

Almost all Servoy applications utilize a database to store user data and application metadata.  Servoy can connect to any database that has a JDBC driver available. Servoy provides a database, Sybase SQL Anywhere, for you if you do not already have a database bundles PostgreSQL by default, but PostgreSQL can be removed and replaced by any database management system (DBMS).

Creating a New Database in

...

PostgreSQL

In Servoy Developer, you may create a new SQL Anywhere PostgreSQL database can be created from the Solution Explorer tree.

  1. In the Servoy Developer Solution Explorer tab, expand the Database Servers node (under Resources) and right click on a SQL Anywhere any PostgreSQL database (all the example databases provided by Servoy are SQL AnywherePostgreSQL) to show the popup menu.
  2. Select Create Sybase PostGreSQL Database.
  3. Enter a name for the database in the dialog window.
  4. A dialog will appear indicating a Sybase as the database restart is requiredbeing created.
  5. A dialog will recommend to restart Servoy Developer.  Click OK. and close Servoy Developer.
  6. Close Sybase SQLAnywhere.
    1. On Windows - Look for the orange lighting bolt in the system tray, right click, and select Shut down "servoy_repository"
    2. On Mac and Linux - find the dbsrv11 process and shut it down.
  7. Restart Servoy Developer.
  8. Your database will appear in the Database Servers nodeAnother dialog will alert that the creation is finished.

Connecting to an Existing Database

You may also connect to an existing database in Servoy Developer.From within Servoy Develop connections to existing databases can also be setup:

  1. Determine the JDBC driver required for making connections to your database.  You can find the the database.  The proper driver can normally be determined from the DBMS manufacturer/documentation; another source that may help is the Servoy Forum as other developers have possibly used your the database with Servoy.
  2. Install the driver by placing the .jar file in the application_server/drivers folder in your Servoy the Servoy installation folder.
  3. Restart Servoy Developer.
  4. Create a new Database Server connection by right clicking on Database Servers node (under Resources) and selecting New Server.  A submenu will provide choices of different popular database choices that will fill in some of the connection information to make setup easier

    , or you may choose empty

    .

    Note
    titleNOTE

    Even though a database is listed here, you the JDBC driver must still install a driver be installed in the drivers folder in order to connect to the database.


  5.  Fill in the Server Name, User Name, Password, URL, and Driver for

    your database.  You can find the

    the database. The correct values for the URL and Driver should be obtained from

    your

    the database documentation, or suggested values will be already entered

    if you selected your database in

    when going through the New Server menu.

    Note
    titleNOTE

    The user account should be of administrator level so you as to have full access to database objects in Servoy.


  6. Save the tab by clicking the save button in the toolbar or using Ctrl-S to save the tab.
  7. Your The database should now appear in the Database Servers list.

Creating Tables and Columns

It is best practice to create your data the data model (tables, primary keys, foreign keys, and fields) before you starting to create your a solution.  You can create objects Objects in the database can be created with database tools built to administer the database, or you may create objects within Servoy Developer.

Creating Tables

To create a table in Servoy Developer:

  1. Right click on the database name in the Database Servers node and select Create Table OR With the database name selected, click on the create table button in toolbar of the list view in Solution Explorer.
  2. A dialog will ask for the name for a new table. Enter the a preferred name and click OK.
  3. The table editor view will appear allowing new columns to be entered.

    Note
    titleNOTE

    When a new table is created, Servoy will add a column in the table editor for the primary key. All tables used in Servoy must have a primary key or a row identifier.


Creating Columns

To create columns in Servoy Developer:

  1. Open the table editor by selecting the database server in the Solution Explorer and doing one of the following in the list view:
    1. Double clicking on the table name.
    2. Right clicking on the table name and selecting Edit table/view.
    3. Select the table and click on the edit table button in the list view toolbar.
  2. The table editor will appear allowing editing of the columns for the table.
  3. To add a column, click on the Add button. Change the name from "'type here" ' to your desired the desired name, the column type, and size (if applicable). Be sure to save when finished.
  4. To remove a column, click on the Remove button. button.

Webinars


Servoy periodically produces Technical Webinars targeted to developers covering a broad range of topics, from new features to new capabilities to best practices.

The following webinar is focused on how Servoy manages some advanced DB functionality like handling failed saves, transactions, record locking and batch updates

Widget Connector
urlhttp://youtube.com/watch?v=5kkBf6rBlAs


The following webinar is focused on the Servoy Query Builder Tool that makes easier to query databases without writing SQL and makes queries database independent

Widget Connector
urlhttp://youtube.com/watch?v=WxPqhJZtr4A