hello ingres! david tondreau, architectdownloads.actian.com/online/media/pdf/application... ·...

34
1 Hello Ingres! David Tondreau, Architect A Multi-Language Introduction to Application Development on the Ingres RDBMS

Upload: others

Post on 30-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

1

Hello Ingres!David Tondreau, Architect

A Multi-Language Introduction to Application Development on

the Ingres RDBMS

Page 2: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

2

What Do I Do First?

Surviving Your First 30 Minutes with Ingres!

Page 3: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

3

Agenda

• Before You Start• Installation Tips for Application Developers• Working With Ingres• Getting Started with .NET• Getting Started with Java• Getting Started with OpenROAD

Page 4: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

4

What You'll Need

• Ingres 2006• www.ingres.com/downloads

• 4GL Developers• OpenROAD 2006 (www.ingres.com/downloads)

• Java Developers• Eclipse/Ingres/DTP Bundle (www.ingres.com/downloads)

• .NET Developers• Visual Studio

Page 5: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

5

Useful Free Resources

• Microsoft Visual Studio Express C# Edition• msdn.microsoft.com/vstudio/express/visualcsharp/

• Sun JRE + NetBeans Bundle• java.sun.com/j2se/1.4.2/download.html

• VMWare Server• www.vmware.com/download/server/

• Acrobat Reader• www.adobe.com/products/acrobat/readstep2.html

• Info-Zip• www.info-zip.org

Page 6: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

6

The “ingres” User Account

• Historically required for Ingres/OpenROAD• In the “Administrator” group (Windows)• Special security privileges required

• Log on as a service• Act as part of the operating system• Log on as a batch job (Everyone)

• Master DBA• Still a good idea (though not technically required)

Page 7: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

7

Installation for Application Developers

Page 8: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

8

Installing Ingres Components

Page 9: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

9

Tip: Install Replicator and Federated DB

• Replicator• Built in low volume replicator service• Supports master/slave and peer to peer

• Federated Database (“Star”)• Provides a means for integrating multiple databases into a

single virtual instance

• Advanced features• Install now and turn off if you think you might want to use• Turn back on later using Ingres Configuration Manager

Page 10: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

10

Enabling Replicator and Star

Page 11: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

11

Tip: Increase the Size of the Ingres Log

• To support:• Importing

large test data sets

• OpenROAD

• Increase the size of the Ingres log to 200MB (or more)

• You can always do it later too

Page 12: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

12

Tip: Select the Right Meaning of “DATE”

Page 13: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

13

Setting the Stage

• An “ingres” account was created is logged on• Ingres 2006 r2 has been installed• Java developers:

• Have downloaded the Ingres/Eclipse/DTP bundle• Have JRE 1.5 downloaded and installed

• .NET developers:• Have Visual Studio or Visual Studio Express installed

• OpenROAD developers:• OpenROAD 2006 has been downloaded and installed

The demos in this presentation assume:

Page 14: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

14

Working With Ingres

• Accessing the Ingres Environment• Starting and Stopping Ingres• Configuring Ingres• Creating and Destroying Databases• Using the Terminal Monitor• Backing up and Restoring Databases

Page 15: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

15

DEMO: Accessing Ingres Command

• System Environment Variables• II_SYSTEM=C:\Program Files\Ingres\IngresII• PATH=%II_SYSTEM%\ingres\bin; %II_SYSTEM

%\ingres\utility

• On Windows• Should have been added into the system environment by

the installer

• On Linux/UNIX• Scripts “.ingIIsh” and “.ingIIcsh” are created in /home/ingres• If only one Ingres installation, add “source .ingIIsh” to your

.bashrc script

Page 16: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

16

Starting and Stopping Ingres

• If installed as a Windows service:• Via the Windows Service Manager• Via Ingres Service Manager or Ingres Visual Manager• Via “net start|stop Ingres_Database_<II>” commands

• Linux/UNIX or not installed as Windows service• Via “ingstart” and “ingstop” commands• Must be run as a priviledged user (e.g., “ingres”)

Page 17: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

17

Starting and Stopping Ingres (cont.)

• TIP #1: Always start Ingres as a service on Windows• If you start Ingres using ingstart on Windows, it runs under

the currently logged in account• When you log off, Ingres will shut down

• TIP #2: Don't mix start and stop as a service with ingstart and ingstop• Getting the Windows service and the running instance out of

sync causes problems

Page 18: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

18

DEMO: Configuring Ingres Services

• Shut down Ingres• Windows: Ingres Visual Manager• Linux: “ingstop”

• Configure Ingres• Windows: Ingres Configuration Manager • Linux: Configuration by Forms (“cbf” command)

• Restart Ingres• Windows: Ingres Visual Manager• Linux: “ingstart”

Page 19: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

19

DEMO: Creating / Destroying Databases

• On Windows:• Visual DBA• “createdb <dbname>” command• “destroydb <dbname>” command

• Warning! Destroys without a confirmation prompt!

• On Linux/UNIX• “createdb <dbname>” command• “destroydb <dbname>” command

Page 20: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

20

Terminal Monitor (i.e., “sql” Command)

• “sql dbname” command• Allows you to run SQL statments and scripts against the

datbase interactively• Supports redirection:

• sql dbname < script.sql [ > script.log ]

• “isql dbname” command• Forms based terminal monitor

Page 21: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

21

DEMO: Terminal Monitor Commands

• “\g” <RETURN> = GO (run the SQL)• “\q” <RETURN> = QUIT (exit Terminal Monitor)• “\r” <RETURN> = RESET/CLEAR BUFFER• “\e” <RETURN> = EDIT BUFFER• “help\g” <RETURN> = LIST USER TABLES• “help <table>” = SHOW DETAILS FOR <table>

Page 22: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

22

Backing Up Databases

• Backing up the entire database (user+internal):• Run the “unloaddb <dbname>” command

• NOTE: ONLY generates the scripts! Does not actually run them!• Run the generated “unload.bat” command

• “unload.ing on” Linux/UNIX

• Example (with extended command syntax)

C:> cd \tempC:> mkdir testdbC:> cd testdbC:> mkdir dataC:> unloaddb testdb -source=data -dest=dataC:> unload

Page 23: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

23

Backing Up Databases

• Backing up the user components only:• Run the “copydb dbname” command

• NOTE: ONLY generates the scripts! Does not actually run them!• Run the generated “copy.out” script using Terminal Monitor

• sql dbname < copy.out

• Example (with extended command syntax)

C:> cd \tempC:> mkdir testdbC:> cd testdbC:> mkdir dataC:> copydb testdb -source=data -dest=dataC:> sql testdb < copy.out

Page 24: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

24

Restoring Databases

• Restoring from an Unload:• The “unloaddb” command also generated “reload.bat”

• “reload.ing on” Linux/UNIX• Create the database• Run the generated “reload.bat” command

• Example

C:> cd \tempC:> cd testdbC:> createdb testdbC:> reload.bat

Page 25: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

25

Restoring Databases

• Restoring user components only:• The “copydb” command also created a “copy.in” script• Create the database• Run the generated “copy.in” script using Terminal Monitor

• sql dbname < copy.in

• Example (with extended command syntax)

C:> cd \tempC:> cd testdbC:> createdb testdbC:> sql testdb < copy.in

Page 26: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

26

Special Note for OpenROAD Developers

• OpenROAD stores all applications and source components in the Ingres internal system catalogs

• Unloaddb will back up your applications• Copydb will not back up your applications• “w4gldev backupapp out <db> <app> <file>” can

also be used

Page 27: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

27

Getting Started with .NET

• Create a C# project• Add the Ingres .NET Data Provider to the project• Add an entry field to the form• Add the code to:

• Connect to Ingres• Set up and run a query• Put the data on the form• Disconnect from Ingres

Page 28: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

28

.NET Code Snippet

using Ingres.Client; ... string location = "Host=localhost;" + "User Id=ingres;PWD=password;" + "Database=testdb"; IngresConnection dbConn = new IngresConnection(location); dbConn.Open(); string sql = "select text from greeting"; IngresCommand ingCmd = new IngresCommand(sql, dbConn); IngresDataReader dataReader = ingCmd.ExecuteReader(); dataReader.Read(); text.Text = dataReader.GetString(0); dataReader.Close(); dbConn.Close();

Page 29: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

29

Getting Started with Java

• Create a Java project• Add the Ingres JDBC Driver to the project• Add the code to:

• Connect to Ingres• Set up and run a query• Write out the value on the console• Disconnect from Ingres

Page 30: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

30

Java Snippetimport java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import com.ingres.jdbc.*;public final class Application { public static void main(String[] args) { IngresDataSource dataSource = new IngresDataSource (); Connection dbConn = null; PreparedStatement statement = null; ResultSet results = null; String text = ""; dataSource.setServerName("localhost"); dataSource.setDatabaseName("testdb"); dataSource.setPortName("II7"); dataSource.setUser("ingres"); dataSource.setPassword("password"); try { dbConn = dataSource.getConnection(); statement = dbConn.prepareStatement("SELECT text FROM greeting"); results = statement.executeQuery(); results.next(); text = (String) results.getObject(1); System.out.println(text); dbConn.close(); } catch (SQLException e) { e.printStackTrace(); } }}

Page 31: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

31

Getting Started with OpenROAD

• Connect to the Database• Create an Application• Create a Frame• Create an Entry Field• Write the SQL

Page 32: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

32

OpenROAD Code Snippet SELECT :text = text FROM greeting; COMMIT;

Page 33: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

33

mailto:[email protected]

Q&A

Page 34: Hello Ingres! David Tondreau, Architectdownloads.actian.com/online/media/pdf/Application... · Getting Started with Java • Create a Java project • Add the Ingres JDBC Driver to

34

More Questions? See You In The Forums!