• No results found

Using the Eclipse Data Tools Platform with SQL Anywhere 10. A whitepaper from Sybase ianywhere

N/A
N/A
Protected

Academic year: 2021

Share "Using the Eclipse Data Tools Platform with SQL Anywhere 10. A whitepaper from Sybase ianywhere"

Copied!
11
0
0

Loading.... (view fulltext now)

Full text

(1)

Using the Eclipse Data Tools Platform with SQL Anywhere 10

A whitepaper from Sybase iAnywhere

(2)

CONTENTS

Introduction 3

Requirements 3

Before you begin 3

Downloading the Data Tools Platform 3

Starting the sample database 3

Creating a driver template and connection profile 4

Connecting to SQL Anywhere 10 7

Querying the SQL Anywhere database 8

(3)

INTRODUCTION

The Eclipse Data Tools Platform (DTP) project is a new top-level project at eclipse.org. Originally proposed by Sybase in February 2005, DTP has attracted strong community support and is currently managed by a committee comprised of Sybase, IBM, and Actuate. It is an open-source initiative that is designed to provide solutions in the data framework and tooling domains.

Examples of what the DTP plug-in allows you to do from within Eclipse include: • Connect to a database (or multiple databases)

• View a database object tree (tables, views, stored procedures, and so on) • Generate data definition language (DDL) from database objects

• Execute DDL commands against a database • Execute SQL queries against a database • View query results in table format

To learn more about DTP, visit http://wiki.eclipse.org/index.php/Data_Tools_Platform_Project. This tutorial shows you how to install the Data Tools Platform Eclipse plug-in and how to use some of its features against a SQL Anywhere 10 database.

REQUIREMENTS

• SQL Anywhere 10.0.1 • DTP 1.5M6 End-user or later

• Depending on what version of DTP you download, you need a specific version of: • Eclipse SDK (at the time of writing, Eclipse 3.2.2 SDK is required)

• EMF runtimes (EMF + SDO) (at the time of writing, EMF 2.2.2 (EMF + SDO) is required) • GEF runtimes (at the time of writing, GEF 3.2.2 is required)

• JRE 1.5 or later

• Sybase jConnect 6.05 (available at

http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/jconnect)

BEFORE YOU BEGIN

DOWNLOADING THE DATA TOOLS PLATFORM

The first thing you need to do is download the DTP plug-in and include it in your Eclipse folder. You may also have to download the EMF and GEF plug-ins if you don't already have them. When you download and extract all the files, you must merge them into your current Eclipse folder, where you typically launch the application from. You can download DTP from the following location, which also has links to all of its dependencies (EMF and GEF): http://www.eclipse.org/datatools/downloads.html. STARTING THE SAMPLE DATABASE

This tutorial uses the SQL Anywhere sample database provided during installation. It is called

demo.db and you can find it in the samples directory of your installation. If you are running on Mac OS X, Linux, or Unix, you must configure the samples by sourcing the file samples/samples_config32.sh

from your SQL Anywhere 10 installation folder. If you are running on Windows, the samples directory is defined by the %SQLANYSAMP10% environment variable.

Stop all databases running on your computer, find the sample database file and change to its directory, and then run the following command from a command prompt:

(4)

This starts a database server called demo, listening on port 2638 (if it is not already busy) with one database called demo.

CREATING A DRIVER TEMPLATE AND CONNECTION PROFILE

This section describes how to define a driver template and create a connection profile that can be used to connect to the sample database.

1. From the Eclipse File menu, choose New> Other. 2. Select Connection Profile.

3. Click Next. Select Sybase ASA as the connection profile type.

4. Click Next. Name the connection profile sqlanywhere10.

5. Click Next. At this step you have to choose a driver, but you do not have any driver templates defined. Click Browse.

6. Click Add to add a new driver template.

(5)

7. Select Sybase JDBC Driver for Sybase ASA 9.x.

• Even though you are connecting to a SQL Anywhere 10 database, you can use this driver template and configure it to use the appropriate settings.

Change the driver name to Sybase JDBC Driver for SQL Anywhere 10.x. • Make sure the Edit New Driver Definition Immediately option is selected.

8. Click OK, and then click the Add Jar/Zip button to browse for the jConnect 6.05 JAR file

jconn3.jar.

9. Set the driver properties at the bottom of the screen as show in the following image:

(6)

10. Click OK.

11. Now that the driver template is defined, select the new driver, and then click OK to continue.

12. Set the connection profile settings as shown below, and then click Finish.

(7)

Now that you have created a connection profile, you can use the Data Source Explorer to connect to the sample database, and view database objects in the object tree.

CONNECTING TO SQL ANYWHERE 10

To connect to the SQL Anywhere sample database, you must open the Data Source Explorer view. 1. From the Window menu, choose Show View > Other.

2. Select Connectivity > Data Source Explorer, and then click OK.

The Data Source Explorer initializes in your Eclipse environment. You can click and drag the title to dock it wherever you like.

If you expand the Databases folder in the view, you should see the connection profile you just created, and any other connection profiles you have created.

3. Right-click the connection profile you just created, and then click Connect.

(8)

If the connection is successful, you should see results similar to the image below. The tables for the SQL Anywhere sample database are located in the GROUPO schema, so expand demo > Schemas > GROUPO > Tables and you should be able to view all of your tables. You can also expand any table for a list of columns and column types.

The Data Source Explorer offers a great deal of functionality in itself. Right-clicking any object allows you to generate DDL for that object. In the image above, generating DDL for the object demo (at the top of the tree) generates DDL for the entire database, whereas generating DDL for the table Contacts just gives you the DDL pertinent to that table. This tool can be used to generate a data definition of any data source you can connect to. As well, right-clicking a table or view gives you a Data sub-menu from which you can edit the information in that table or view, or sample its contents.

QUERYING THE SQL ANYWHERE DATABASE

Before you can query the database, you must open the SQL Results view. This view is a window view that is populated with data in table format when a query is executed.

1. From the Window menu, choose Show View > Other. 2. Choose SQL Development > SQL Results.

3. Click OK.

(9)

Next, you must open a new SQL File, which you can use to create and execute SQL commands.

4. Choose File > New > Other.

5. Choose SQL Development > SQL File.

6. Click Next.

Now you must specify what project this SQL File will belong to, and what connection profile it will be executed against.

7. Fill out the form as show below, and be sure to choose the right connection profile and database name. Create a new general project if necessary.

(10)

8. Click Finish.

9. Enter any SQL statement into your new SQL File. For example, SELECT * FROM Customers.

10. Save the file, right-click anywhere in the SQL File window, and then choose Execute All.

If your SQL statement executes successfully, you should see results of the statement in the Results view that you opened earlier. If the statement was a query, the Results view displays the returned records. If it was not a query, you receive notification of the statement's success, and how many rows were affected. Query results should look like the image below.

(11)

This completes the tutorial. You can now close Eclipse and shut down the demo database you started earlier.

SUMMARY

In this tutorial, you learned to: • Define a driver template • Create a connection profile

• Connect to a SQL Anywhere 10 database

• Run SQL statements against a SQL Anywhere 10 database from within the Eclipse IDE The activities you walked through in this tutorial are just an introduction to some of the features available in the DTP framework and tools. Hopefully it has given you enough familiarity to continue exploring on your own. Since DTP is an open-source project, they depend on involvement from the community to a large extent. You should feel free to contribute bug reports, feature requests, and general comments to the DTP project team. Their project home page is located at

http://www.eclipse.org/datatools.

COPYRIGHT © 2007 IANYWHERE SOLUTIONS, INC. ALL RIGHTS RESERVED. SYBASE, AFARIA, SQL ANYWHERE, ADAPTIVE SERVER ANYWHERE, MOBILINK, ULTRALITE, AND M-BUSINESS ANYWHERE ARE TRADEMARKS OF SYBASE, INC. ALL OTHER TRADEMARKS ARE PROPERTY OF THEIR RESPECTIVE OWNERS.

References

Related documents

Rapid SQL XE provides a Database Explorer that lets you navigate your datasources and view details on individual objects. The explorer provides a hierarchical view, letting you

L’organisation comptable avant tous nous permet de classer chronologiquement un dossier avant qu’il soit traité après le classement on passe aux écritures comptables, ce dernier est

If you have created a database using SQL Server authentication, you should uncheck the “Create ODBC data source for database” checkbox, continue on, and rerun the installer again

Develop and implement a cross college systematic analysis of human, financial, and physical resources including measurements of efficiency related to teaching / learning methods

In case you to restore a database using the SQL Management Studio and then use the client software to connect to that database, then you will need to install Coffalyser.Net, but

Once your database has been uploaded to your SQL database and you have tested your connection to your SQL database using Team- SQL, you can make SQL the active database to force

In Object Explorer, you connect to an instance of the SQL Server 2005 database engine, expand that instance, expand Databases and the relevant application database, navigate to

This document describes how to connect to a SQL database from a Monitouch panel. There are several components to the system: SQL Database, ODBC Driver, V-Server and Monitouch. This