Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Introducing Eclipse DTP for Ingres An Introduction GIUA Juni 2007 J. Peel Ingres Corp.

Similar presentations


Presentation on theme: "1 Introducing Eclipse DTP for Ingres An Introduction GIUA Juni 2007 J. Peel Ingres Corp."— Presentation transcript:

1 1 Introducing Eclipse DTP for Ingres An Introduction GIUA Juni 2007 J. Peel Ingres Corp

2 2 Overview Open Source Development Tool Eclipse, DTP and Ingres Database Browsing and Editing Examples

3 3 Ingres Business Open Source DBMS Developer IDE? Promote Ingres Uptake Promote Community Involvement

4 4 Eclipse Advanced Development Framework Plug-ins provide functionality Java Java IDE CDT: C/C++ IDE DTP: Data Tools Platform

5 5 Eclipse DTP Access to SQL Data Sources Eclipse “Look and Feel” Browse Edit View

6 6 Eclipse Plug-In Architecture Ingres DTP Connectivity Schema Browsing Ingres SQL Syntax Ingres DB Entities Eclipse Framework Workspace EMF GEF DTP Ingres

7 7 Ingres Eclipse Functionality Browse Database Objects Tables Stored Procedures Triggers (Rules) Ad Hoc SQL

8 8 Ingres Plug-in Overview

9 9 Tables Example

10 10 Stored Procedures Example

11 11 Example: Database Schema Create Audit: Table Procedure Rule

12 12 Database Schema Development Audit New Routes Added New Schema Components: Audit Table:route_new Stored Procedure:route_add_dbp Trigger on Table:route_add_rul

13 13 Create Table routes_added Example

14 14 Create Stored Procedure Example

15 15 Create Audit Rule Example

16 16 Test New Rule Example

17 17 Checking Rule Example Continued

18 18 Example: BEFORE Rule Create BEFORE Rule

19 19 Before Rule New in 2006r2 Triggers before Ingres updates the base table Prevent unwanted updates For Example Where no flight slots available Procedure and BEFORE Rule

20 20 Saving before procedure

21 21 Before Rule Example

22 22 Test BEFORE Trigger Example

23 23 Example: Develop an application Simple Application

24 24 Developing A Simple Application Connect to database Insert a new Country Retrieve all Countries Disconnect

25 25 Create Java Project

26 26 Add JDBC Driver Libraries Tab Add full path to iijdbc.jar

27 27 Create Class File  New  Class Package com.ingres.one Name CountryList Check public static void main

28 28 Class Member Variables // URL Components private static String demoHost = "localhost"; private static String demoPort = "AF7"; private static String demoDb = "demodb3"; private static String demoUser = "user=ingres"; private static String demoPassword = "password=my_password"; // JDBC Connection variables private static String demoDbUrl = "jdbc:ingres://" + demoHost + ":" + demoPort + "/" + demoDb + ";" + demoUser + ";" + demoPassword; private static Connection conn = null; private static Statement stmt = null; private static String tableName = "country"

29 29 Create method main() public static void main(String[] args) { createConnection(); System.out.println("Insert Switzerland (CH)..."); insertCountry("CH", "Switzerland"); System.out.println("Retrieve and print all countries found:"); retrieveCountries(); // Clean up removeCountry("CH"); }

30 30 Create Connection private static void createConnection() { try { Class.forName( "com.ingres.jdbc.IngresDriver").newInstance(); //Get a connection conn = DriverManager.getConnection(demoDbUrl); } catch (Exception except) { except.printStackTrace(); }

31 31 Create insertCountry() method private static void insertCountry(String countryCode, String countryName) { stmt = conn.createStatement(); stmt.execute("INSERT INTO " + tableName + "( ct_id, ct_code, ct_name )" + " VALUES (" + "NEXT VALUE FOR ct_id, '" + countryCode + "','" + countryName +"')"); stmt.close(); }

32 32 Retrieve and Print, 1 retrieve private static void retrieveCountries() { stmt = conn.createStatement(); ResultSet results = stmt.executeQuery( "SELECT ct_name, ct_code " + "FROM " + tableName); ResultSetMetaData rsmd = results.getMetaData(); The code to print the data is on the next slide…

33 33 Retrieve and Print, 2: print for (int i=1; i<=numberCols; i++) { //print Column Names System.out.print(rsmd.getColumnLabel(i)+ "\t\t"); } //print Column Names while(results.next()) { String countryName = results.getString(1); String countryCode = results.getString(2); System.out.println(countryCode + "\t\t" + countryName); } results.close(); stmt.close(); }

34 34 Remove added data private static void removeCountry(String countryCode) { stmt = conn.createStatement(); stmt.execute("delete from " + tableName + " where ct_code = '" + countryCode + "'"); stmt.close(); }

35 35 Try / Catch Error handling has been removed Try / Catch similar to: try { /* Exception generating code block */ } catch (Exception except) { except.printStackTrace(); }

36 36 Running Ingres Application

37 37 Example: Import a Project Import the source from the IFF project

38 38 Importing Project Source Overview

39 39 Launching The Application Select the project com.ingres.demoapp Context Menu: Run As…  Eclipse Application

40 40 Launching the Application: Example

41 41 Running The Application Example

42 42 Ingres Functionality Demonstrated Simple SELECT CountryDAO: getCountries() Dynamic SELECT AirportDAO: getRegionsByCountry() Stored Procedure AirportDAO: getAirportsByRegion()

43 43 Calling An Ingres Stored Procedure

44 44 Summary Eclipse and Ingres DTP plug-in Browse Database Ad hoc SQL Work with: Tables, Procedures, Triggers Examples Develop Schema BEFORE TRIGGER Simple Application Import IFF Demo

45 45 Questions? Answers!

46 46 Introducing Eclipse DTP for Ingres An Introduction GIUA Juni 2007 J. Peel Ingres Corp Danke schön!


Download ppt "1 Introducing Eclipse DTP for Ingres An Introduction GIUA Juni 2007 J. Peel Ingres Corp."

Similar presentations


Ads by Google