how to setup ingres to work with your...
TRANSCRIPT
How to Setup Ingres to Work with Your Application
Cristian Ianculovici
Why Ingres Database?
Bells andWhistles
Enterprise
Developer
SmallBusiness
Hobby
Closed Source Entry Level Closed Open Source
Feat
ure
Bre
adth
and
Dep
th
Total Cost of OwnershipExpensive Inexpensive
SybaseProgress
SQL Server
ORCL 10gIBM DB2Teradata
ExpressVersionsof closedsource
PostgresMySQL
INGRES
INGRES in DATAllegro
Slide 2© 2008 Ingres Corporation
Applications and Database Connectivity
Ingres Database
© 2008 Ingres Corporation Slide 3
Applications and Database Connectivity
Ingres Database
Ingres Tools and Applications
© 2008 Ingres Corporation Slide 3
Applications and Database Connectivity
There are various ways of classifying applications as far as the Ingres backend is concerned
Native Tools that are Ingres specific– Terminal Monitor, ABF, Embedded SQL, ICE– Visual SQL– OpenROAD
Standard (generic) Common tools that are used by different database systems– ODBC, JDBC, .NET– PHP, Python, Perl, Hibernate, Torque
© 2008 Ingres Corporation Slide 4
Applications and Database Connectivity
Other classifications are based on:
Performance Complexity New development / Legacy
© 2008 Ingres Corporation Slide 5
Choosing the right tools
This presentation is about how to connect existing or newly developed applications to Ingres
© 2008 Ingres Corporation Slide 6
Agenda
Ingres Remote Connectivity Using ODBC JDBC Connectivity VB.NET The Python DBI Driver Ingres Native Tools – Terminal Monitor Embedded SQL OpenROAD Choosing the right tools
© 2008 Ingres Corporation Slide 7
Ingres Remote Connectivity
Using V-nodes
© 2008 Ingres Corporation Slide 8
V-node Connectivity
Connecting using the SQL utility (Terminal Monitor)
© 2008 Ingres Corporation Slide 9
Using ODBC
Create an ODBC Data Source (DSN
© 2008 Ingres Corporation Slide 10
Using ODBC – Ingres DSN
© 2008 Ingres Corporation Slide 11
ODBC Connection – Excel Example
© 2008 Ingres Corporation Slide 12
ODBC Connection – Excel Example
© 2008 Ingres Corporation Slide 13
ODBC Connection – Code Example
MS Visual BasicDim con As ADODB.ConnectionDim rs As ADODB.RecordsetDim ConnStr As StringDim Query As String
Sub Main() Set con = New ADODB.Connection Set rs = New ADODB.Recordset ConnStr = "DSN=testdb" con.Open ConnStr
© 2008 Ingres Corporation Slide 14
ODBC Connection – Code Example
MS Visual Basic (continued)
Query = "SELECT date('now')" Do While Not rs.EOF currentDBDateAndTime = rs(1) rs.MoveNext Loop rs.Close
© 2008 Ingres Corporation Slide 15
JDBC / .NET
Ingres Database
© 2008 Ingres Corporation Slide 16
JDBC / .NET
Ingres Database
Ingres Tools and Applications
JDBC ApplicationJDBC Driver
.NET Data Provider
.NET Application
© 2008 Ingres Corporation Slide 16
JDBC / .NET
Ingres Database
Ingres Tools and Applications
Data Access Server
JDBC ApplicationJDBC Driver
.NET Data Provider
.NET Application
© 2008 Ingres Corporation Slide 16
JDBC Connectivity
Code example
Class.forName("com.ingres.jdbc.IngresDriver");Connection con = DriverManager.getConnection( "jdbc:ingres://localhost:II7/testdb", "ingres", "*****");Statement st = con.createStatement();query = "INSERT INTO mydate VALUES(date('now'))";st.execute(query);st.close();
© 2008 Ingres Corporation Slide 17
Other Standard Tools
The Ingres .NET Data Provider
© 2008 Ingres Corporation Slide 18
Other Standard Tools (continued)
C#: public sealed class IngresCommand : System.Data.Common.DbCommand, IDbCommand,
IDisposable, ICloneable VB.NET: NotInheritable Public Class IngresCommand Inherits System.Data.Common.DbCommand Implements IDbCommand, IDisposable, ICloneable
© 2008 Ingres Corporation Slide 19
Other Standard Tools (continued)
IngresCommand Class Example IngresCommand cmd = new IngresCommand( “SELECT id, name FROM employee WHERE id = ?”);
© 2008 Ingres Corporation Slide 20
Other Standard Tools (continued)
The Python DBI Driverimport ingresdbi
dc=ingresdbi.connect(vnode="prod",database="testdb")c=dc.cursor()c.execute("select date('now')")for row in c.fetchall(): dt = row[0]print dtdc.commit()c.close()dc.close()
© 2008 Ingres Corporation Slide 21
Ingres Native Tools – Terminal Monitor
Easiest to use– Just type the query, end it with \g <Enter> and see the
results of the query.
© 2008 Ingres Corporation Slide 22
Ingres Native Tools – Terminal Monitor
Used for running scripts– Example.sql:INSERT INTO test_table (col1, col2) VALUES (‘abc’, 123);\g
To run: sql database_name < Example.sql– copydb generates files that are later executed using
this command.
© 2008 Ingres Corporation Slide 23
Ingres Native Tools – Embedded SQL
C is the most common but there are packages for Pascal, Fortran, Cobol
It allows you to write SQL inside your program using your preferred programming language
Before going through the typical building steps, the program needs to be precompiled
© 2008 Ingres Corporation Slide 24
Ingres Native Tools – Embedded SQL (continued)
#include <stdio.h>EXEC SQL INCLUDE SQLCA;EXEC SQL BEGIN DECLARE SECTION; /* database name */ static char dbname[20]; /* query output */ static char output[100]; /* error message */ static char errmsg[100];EXEC SQL END DECLARE SECTION;
© 2008 Ingres Corporation Slide 25
Ingres Native Tools – Embedded SQL (continued)
main(){ strcpy(dbname,"testdb"); printf("Connecting to <%s> ... ", dbname); EXEC SQL WHENEVER SQLERROR CALL error; EXEC SQL CONNECT :dbname; printf("Done. \n"); EXEC SQL SELECT date('now') INTO :output; printf("Date/Time on the server is: %s\n",output);}
© 2008 Ingres Corporation Slide 26
Ingres Native Tools – Embedded SQL (continued)
error(){ EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL INQUIRE_SQL(:errmsg = ERRORTEXT); printf("\nAn error has occured: \n%s\n",errmsg); exit(1);}
© 2008 Ingres Corporation Slide 27
Ingres Native Tools – Embedded SQL (continued)
Precompile: esqlc myTest.sc Compile/link:
– Windowscl myTest.c /link ^ %II_SYSTEM%\ingres\lib\libingres.lib– UNIX (Linux)cc myTest.c -o myTest \$II_SYSTEM/ingres/lib/libingres.a -lm -lc –ldl \-lpthread
© 2008 Ingres Corporation Slide 28
OpenROAD
Open Rapid Object Application Development Platform independent
How to connectThere are three modes:– No connectivity– Specify a database (named)– Connect to the current database
© 2008 Ingres Corporation Slide 29
OpenROAD (continued)
© 2008 Ingres Corporation Slide 30
OpenROAD (continued)
© 2008 Ingres Corporation Slide 31
OpenROAD (continued)
Running the simple OpenROAD application
© 2008 Ingres Corporation Slide 32
OpenROAD (continued)
© 2008 Ingres Corporation Slide 33
OpenROAD (continued)
Other OpenROAD components
– Web deployment - eClient – OpenROAD Server – nTier Distribution– mClient - Mobile
© 2008 Ingres Corporation Slide 34
© 2008 Ingres Corporation Slide 35
The following need to be considered when choosing the tools
© 2008 Ingres Corporation Slide 35
The following need to be considered when choosing the tools
© 2008 Ingres Corporation Slide 35
The following need to be considered when choosing the tools
Complexity
© 2008 Ingres Corporation Slide 35
The following need to be considered when choosing the tools
Complexity Performance
© 2008 Ingres Corporation Slide 35
The following need to be considered when choosing the tools
Complexity Performance User interaction
© 2008 Ingres Corporation Slide 35
The following need to be considered when choosing the tools
Complexity Performance User interaction Legacy applications
© 2008 Ingres Corporation Slide 35
Confidential — © 2008 Ingres Corporation Slide 36
ResourcesIngres Connectivity Guide
Embedded SQL Companion Guideingres.com
community.ingres.com