Difference between revisions of "Scout/Tutorial/3.9/Add JDBC Drivers for Eclipse Scout"

From Eclipsepedia

< Scout‎ | Tutorial‎ | 3.9
Jump to: navigation, search
(Creating a SQL Service)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
{{note|Note|This page needs to be checked and updated to fit 3.9}}
 
 
 
{{ScoutPage|cat=Tutorial 3.9}}
 
{{ScoutPage|cat=Tutorial 3.9}}
 
== Introduction ==
 
== Introduction ==
Line 25: Line 23:
 
== Creating a SQL Service ==
 
== Creating a SQL Service ==
  
To make use of the new driver we create a new [http://wiki.eclipse.org/Scout/Concepts/Sql_Service SQL Service]. For this go to 'Server' |'Common Services' | 'SQL Services', righ click and choose 'New SQL Service...' [http://wiki.eclipse.org/Image:Scout.jdbc.driver.new.sqlservice.png]. In the wizard type 'PostgreSQL9' in the class name, choose 'AbstractPostgresSqlService' as super class [http://wiki.eclipse.org/Image:Scout.jdbc.driver.new.sqlservice.01.png] and press 'Finish'.  
+
To make use of the new driver we create a new [http://wiki.eclipse.org/Scout/Concepts/Sql_Service SQL Service]. For this go to 'Server' |'Common Services' | 'SQL Services', righ click and choose 'New SQL Service...' [http://wiki.eclipse.org/Image:Scout.jdbc.driver.new.sqlservice.png]. In the wizard type 'Postgre' in the class name, choose 'AbstractPostgreSqlService' as super class [http://wiki.eclipse.org/Image:Scout.jdbc.driver.new.sqlservice.01.png] and press 'Finish'.  
  
 
Select the new created SQL service in the 'Scout Explorer' and configure the properties 'Username', 'Password' and 'Jdbc Mapping Name' according to the setup of your database.
 
Select the new created SQL service in the 'Scout Explorer' and configure the properties 'Username', 'Password' and 'Jdbc Mapping Name' according to the setup of your database.
Line 33: Line 31:
 
== Accessing data on the database ==
 
== Accessing data on the database ==
  
Now we will access the database for our simple helloworld project. For this go to 'Server' | 'Process Services' | 'DesktopProcessService' | 'load' and double click on the 'load' operation. Implement the method as follows:
+
Now we will access the database for our simple helloworld project. For this go to 'Server' | 'Services' | 'DesktopService' | 'load' and double click on the 'load' operation. Implement the method as follows:
 
<source lang="java" line="GESHI_NORMAL_LINE_NUMBERS" start="1">
 
<source lang="java" line="GESHI_NORMAL_LINE_NUMBERS" start="1">
 
public DesktopFormData load(DesktopFormData formData) throws ProcessingException {
 
public DesktopFormData load(DesktopFormData formData) throws ProcessingException {
Line 46: Line 44:
  
 
== See Also ==
 
== See Also ==
If the desired JDBC driver is not yet available, follow {{ScoutLink|HowTo/3.8|Write_a_jdbc_connection_bundle|this}} to learn how to create your own driver bundle.
+
If the desired JDBC driver is not yet available, follow {{ScoutLink|HowTo/3.9|Write_a_jdbc_connection_bundle|this}} to learn how to create your own driver bundle.

Latest revision as of 08:35, 10 September 2013


Scout
Wiki Home
Website
DownloadGit
Community
ForumsBlogTwitter
Bugzilla
Bugzilla

Contents

[edit] Introduction

Scout ships with one JDBC driver for the Derby database. If you want to use other databases you can add JDBC drivers for those by installing the corresponding driver. Drivers for Oracle, PostgreSQL and MySQL are published in the Eclipse Marketplace. This tutorial explains how to add JDBC drivers and create a SqlService using the Scout SDK.

[edit] Preparation

First we create a new Scout "Hello World" application as described in the Hello World tutorial.

[edit] Installation of JDBC Drivers using Scout SDK

In the 'Scout Explorer' view select the project node and expand the corresponding 'Technologies' section in the 'Scout Object Properties' view (if not already expanded) [1]. In this section there is a group named 'Database Drivers' with a checkbox for each JDBC driver that is available. All drivers that are checked, will be available to the selected Scout project. By default a new Scout project has the Derby JDBC driver active.

For this tutorial we will use a PostgreSQL driver instead. But the steps are the same for the other drivers as well.

First, uncheck the box named 'Derby JDBC Driver for Eclipse Scout'. A popup dialog appears listing all resources that can be modified. Ensure all checkboxes are ticked and confirm with the OK button [2]. Now, the Derby driver is no longer part of the Scout project.

Then we check the box named 'PostgreSQL 9 JDBC Driver for Eclipse Scout'. Again: ensure all boxes are checked in the popup dialog and confirm with OK. If this is the first time you are using the PostgreSQL driver for the running Eclipse, it will be downloaded from the Eclipse Marketplace and installed in your Eclipse instance. In that case another popup dialog apears allowing you to read and accept the license of the driver [3]. As soon as the license has been accepted the download starts (this may take a while). When the download has been completed successfully, confirm the security warning [4] with OK and choose to restart Eclipse on the next popup box.

The JDBC driver is now installed in your Eclipse instance and the helloworld project is configured to have the driver available.

[edit] Creating a SQL Service

To make use of the new driver we create a new SQL Service. For this go to 'Server' |'Common Services' | 'SQL Services', righ click and choose 'New SQL Service...' [5]. In the wizard type 'Postgre' in the class name, choose 'AbstractPostgreSqlService' as super class [6] and press 'Finish'.

Select the new created SQL service in the 'Scout Explorer' and configure the properties 'Username', 'Password' and 'Jdbc Mapping Name' according to the setup of your database.

The SQL service is now created and ready to be used.

[edit] Accessing data on the database

Now we will access the database for our simple helloworld project. For this go to 'Server' | 'Services' | 'DesktopService' | 'load' and double click on the 'load' operation. Implement the method as follows:

  1. public DesktopFormData load(DesktopFormData formData) throws ProcessingException {
  2.   SQL.selectInto("SELECT 'Hello World!' INTO :message", formData);
  3.   return formData;
  4. }
Note.png
Note
Some database system require a FROM clause in the SQL statement. For these use 'SELECT 'Hello World!' FROM dual INTO :message' as statement.


Start the application as described in the Hello World tutorial.

[edit] See Also

If the desired JDBC driver is not yet available, follow this to learn how to create your own driver bundle.