31
1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

Embed Size (px)

Citation preview

Page 1: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

1

How to Improve Database Connectivity With the Data Tools Platform

John Graham (Sybase Data Tooling)Brian Payton (IBM Information Management)

Page 2: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

2

Agenda

• DTP Overview• Creating a Driver Template• Creating a Connection Profile• Customizing a Database Definition• Extending the SQL Query Parser• Conclusion

Page 3: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

3

DTP Structure

• Top level project at Eclipse• Contains four subprojects

– Model Base– Connectivity– SQL Dev Tools– Enablement

Page 4: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

4

Model Base

• Domain models for data centric applications using EMF

• Currently– SQL– SQL Query– SQL XML Query– Database Definition

Page 5: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

5

Connectivity

• Create and manage connections to data sources

• Frameworks– Driver Management– Connection Management– ODA

• Data Source Explorer

Page 6: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

6

SQL Dev Tools

• Developer centric SQL tools• Frameworks

– Editor– Results view– SQL Query Parser

• Tools– SQL Editor– Script history– Results

Page 7: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

7

Enablement

• For specialization of DTP to specific data sources

• Examples– Specific databases– XML data source

• Other data sources?

Page 8: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

8

Support for PostgreSQL 8.x

• Can define generic driver template• Can connect using JDBC connection

profile• Can use SQL Dev with this connection

profile

Page 9: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

9

Demonstration:Connecting to PostgreSQL

Page 10: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

10

Limitations

• Not intuitive for driver and connection profile definitions

• Not all data types correct• Not all database objects appear in DSEWe will address the first two today

Page 11: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

11

Driver Template

• Specify reasonable defaults for PostgreSQL 8.x

• Reuse generic driver template• Make the choice obvious in the driver

template list

Page 12: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

12

Demonstration:Creating a Driver Template

Page 13: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

13

Connection Profile

• Simple reuse of the generic JDBC connection profile (for now)

• Responsibilities– Manage connection on request– Provide meta-data about connection

Page 14: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

14

Demonstration:Creating a Connection Profile

Page 15: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

15

Further (future) specializations

• Specialized class loading• Specialized content for DSE• Contribute to SQL Dev extension points

Page 16: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

16

Data Type Problems

• Why is this happening?• Specialize database definition

– Modify XMI vendor file– Based on generic version– Add new names for data types

Page 17: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

17

Demonstration:Specialized DB Definition

Page 18: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

18

Using the DB Customization

Specialized types added• (Future) Support all data types in a

similar manner

Page 19: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

19

Beyond Connecting

• Now that you have a (customized) connection to your database, what can you do with it?– All kinds of things, but here are some important

ones:• Retrieve data• Update data

– Retrieving and updating data typically requires creating SQL queries

Page 20: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

20

SQL Facts of Life

• Each database type has its own flavor of SQL– No database really implements the ISO SQL

standard– Each has missing features, added non-standard

features, and some features present but just different

• This creates a problem for database tools!– Need a way to create tools that can handle the

differences

Page 21: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

21

DTP SQL Query Parser

• DTP includes a SQL Query parser framework and example implementation

• Parses SQL DML statements:– SELECT, INSERT, UPDATE, DELETE

• Based on IBM LALR Parser Generator (LPG)• Output of parser is instance of SQL Query

Model• Both parser and model are designed to be

customized and extended

Page 22: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

22

Example: PostgreSQL

• PostgreSQL has lots of interesting features and differences from standard SQL. Here are two we will use for our example extension:– Additional table join types– Dollar-quoted string constants

Page 23: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

23

PostgreSQL: Additional table join types

• PostgreSQL supports many table join types, including some unusual ones:– CROSS JOIN– NATURAL JOIN

• These are in ISO SQL but are not in many other DB’s, and are not included in the base SQL Query model and parser

• Will illustrate how to extend the SQL Query model and parser

Page 24: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

24

PostgreSQL: Dollar-quoted string literals

• PostgreSQL has an unusual alternative syntax for specifying string literals in SQL– $$string literal here$$– Can include any characters inside the literal

(avoids the need to double single quotes)• Typically used to “quote” SQL code in

procedure and function definitions• Will illustrate how to extend the SQL lexer

Page 25: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

25

Task Overview: Extending the Model

1. Create plugin for model extension2. Define the model extension3. Generate model code (EMF)4. Extend the source formatter

Page 26: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

26

Demonstration:Extending the SQL Query Model

Page 27: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

27

Task Overview: Extending the Parser

1.Create plugin for parser extension2.Copy and modify LPG templates3.Define LPG command runner4.Add and override parser rules5.Generate parser code

Page 28: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

28

Demonstration:Extending the SQL Query Parser

Page 29: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

29

Task Overview: Extending the Lexer

• In LPG, the lexer is a specialized parser, so steps are similar to the parser steps

1. Copy LPG lexer template2. Modify grammar rules in lexer3. Generate lexer code

Page 30: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

30

Demonstration:Extending the SQL Lexer

Page 31: How to Improve Database Connectivity With the Data …. How to Improve...1 How to Improve Database Connectivity With the Data Tools Platform John Graham (Sybase Data Tooling) Brian

31

Putting it all together

• Now have a SQL parser and model that work together. Can be used for:– Query analysis– Query building– Query syntax checking