* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download How to Setup Ingres to Work with Your Application Cristian Ianculovici
Microsoft Access wikipedia , lookup
Concurrency control wikipedia , lookup
Oracle Database wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Database model wikipedia , lookup
Clusterpoint wikipedia , lookup
Relational model wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
How to Setup Ingres to Work with Your Application Cristian Ianculovici Bells and Whistles Enterprise Developer Small Business Hobby Feature Breadth and Depth Why Ingres Database? INGRES in DATAllegro ORCL 10g IBM DB2 Teradata INGRES Sybase Progress SQL Server Expensive Total Cost of Ownership Closed Source © 2008 Ingres Corporation Express Versions of closed source Entry Level Closed Slide 2 Postgres MySQL Inexpensive Open Source Applications and Database Connectivity Ingres Database © 2008 Ingres Corporation Slide 3 Applications and Database Connectivity Ingres Tools and Applications Ingres Database © 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 Basic Dim con As ADODB.Connection Dim rs As ADODB.Recordset Dim ConnStr As String Dim 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 JDBC Application Ingres Tools and Applications JDBC Driver .NET Data Provider .NET Application Ingres Database © 2008 Ingres Corporation Slide 16 JDBC / .NET JDBC Application Ingres Tools and Applications JDBC Driver Data Access Server .NET Data Provider .NET Application Ingres Database © 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 Driver import 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 dt dc.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: – Windows cl 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 connect There 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 Resources Ingres Connectivity Guide Embedded SQL Companion Guide ingres.com community.ingres.com Confidential — © 2008 Ingres Corporation Slide 36