Connecting to Databases. connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as.

Slides:



Advertisements
Similar presentations
Other Web Application Development Technologies. PHP.
Advertisements

Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Copyright  Oracle Corporation, All rights reserved. 2 Java and Databases: An Overview.
W EB A PPLICATION D EVELOPMENT A PPLICATION T O B IO -I NFORMATICS -III Vicky Khanna M-Tech Bioinformatics.
Java Database Connectivity (JDBC). 2/24 JDBC (Java DataBase Connectivity) - provides access to relational database systems JDBC is a vendor independent.
Java and Databases CS-328 Dick Steflik. Database Drivers Think of a database as just another device connected to your computer like other devices it has.
Fundamentals, Design, and Implementation, 9/e Chapter 12 ODBC, OLE DB, ADO, and ASP.
Distributed Application Development B. Ramamurthy.
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
ODBC Open DataBase Connectivity a standard database access method developed by Microsoft to access data from any application regardless of which database.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
Dale Roberts 8/24/ Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
September 6, 2015 Connecting Client Applications to Informix Databases using IBM Informix Connect and ODBC James Edmiston Database Consultant Quest Information.
1 Java Database Connection (JDBC) There are many industrial-strength DBMS's commercially available in the market. Oracle, DB2, and Sybase are just a few.
JDBC Java Database Connectivity. What is an RDBMS? Relational database management system. There are other kinds of DBMS. Access is a GUI on a JET RBDMS.
Oracle8 JDBC Drivers Section 2. Common Features of Oracle JDBC Drivers The server-side and client-side Oracle JDBC drivers provide the same basic functionality.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
PHP Data Object (PDO) Khaled Al-Sham’aa. What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform interface.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
M1G Introduction to Database Development 6. Building Applications.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Universal Data Access and OLE DB. Customer Requirements for Data Access Technologies High-Performance access to data Reliability Vendor Commitment Broad.
Mainframe (Host) - Communications - User Interface - Business Logic - DBMS - Operating System - Storage (DB Files) Terminal (Display/Keyboard) Terminal.
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
Java Database Connectivity (JDBC). Topics 1. The Vendor Variation Problem 2. SQL and Versions of JDBC 3. Creating an ODBC Data Source 4. Simple Database.
JDBC. Java.sql.package The java.sql package contains various interfaces and classes used by the JDBC API. This collection of interfaces and classes enable.
PHP Workshop ‹#› PHP Data Object (PDO). PHP Workshop ‹#› What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform.
JDBC CHAPTER-2. JDBC - Java Database Connectivity. JDBC from Sun Microsystems provides API or Protocol to interact with different databases. With the.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
UNIT III - JDBC JDBC Overview – JDBC implementation – Connection class – Statements - Catching Database Results, handling database Queries. Networking–
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
WEB SERVER SOFTWARE FEATURE SETS
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Database Connectivity and Server-Side Scripting Chapter 12.
Basics of JDBC Session 14.
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
JDBC Chapter 1 JDBC Introduction
Ch. NoNameMarks 01AWT24 02Networking18 03JDBC20 04Swing18 05Servlet20 Advance Java Programming.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
JDBC. Database is used to store data permanently. These days almost all Applications needs database to store its data persistently. Below are the most.
DEPTT. OF COMP. SC & APPLICATIONS
Note: To complete the examples in this section you need access to a database!! Most of the examples work for any database with JDBC drivers. However, connecting.
Accessing the Database Server: ODBC, OLE DB, and ADO
ODBC, OCCI and JDBC overview
The Client/Server Database Environment
Multitier Architecture, MySQL & PHP
PHP / MySQL Introduction
Mr. Harish Sharma Asst. Professor Dept. of CA & IT SGRRITS Dehradun
Interacting with Database
Lecture 1: Multi-tier Architecture Overview
Java Database Connectivity
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Chapter 10 ADO.
JAVA DATABaSE CONNECTIVITY
Java API for Database Connectivity
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Presentation transcript:

Connecting to Databases

connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as web server Separate machine for larger sites DB server examples: –MySQL, PostgreSQL - free –SQL Server, Oracle - commercial

relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit and rollback –different SQL dialects –auto-numbered table rows –programming

connection technologies ODBC –Access, SQLServer, most databases have an ODBC interface –Excel, CSV files JDBC –most databases have JDBC drivers OLE DB –Windows only specific database drivers client libraries –database specific APIs

common tasks locking mechanisms –exclusive locks –read-only (sharing) locks) database connection –data source name (DSN) –userID –password

common tasks query the database retrieve a result set process the result set error handling release resources

Database Connectivity with Perl CGI

DBM files classic Perl data format essentially persistent associative arrays –elements are key-value pairs look up values using keys perform efficient insertion/deletion of values

DBM Example File1.pl dbmopen(%vals,"test.db",0666) || die("Can't open DB!"); $vals{'name1'}="Douglas"; $vals{'name2'}="Adams"; dbmclose(%map); File2.pl dbmopen(%vals,"test.db",0666) || die("Can't open DB!"); print $vals{'name1'}; print $vals{'name2'} dbmclose(%map);

CSV files Comma Separated Value text format use DBI module with DBD:CSV module allows SQL manipulation of CSV files only simple queries possible slower than conventional text processing good prototyping approach before moving to an RDBMS

Perl DBI module abstract set of tools to interact with (relational) databases uses database specific drivers (DBD) to implement commands –DBD modules DBD:ODBC DBD:Oracle DBD:CSV etc

interaction with databases prepare –parse SQL –validate SQL –create a statement handle execute –passes statement to database –database constructs query results

interaction with databases fetch –query results pulled into Perl data structures –processing then carried out on fetched data deallocation –release of database resources at end of processing –clears memory, removes any locks –handled automatically

Example... use DBI; my $db = DBI->connect ("dbi:Oracle:fridge", "user", "pass"); my $sql = $db->prepare ("SELECT * FROM FREEZER"); = $sql->fetchrow_array();...

summary of Perl DBI powerful approach DBD modules available for most databases available on most platforms –compatibility problems with different Perl versions CGI not suitable for high-end systems –speed and security problems flock command –exclusive locks or sharing locks –resources released when filehandles are destroyed

database connectivity with PHP

database-specific extensions written in C++ non-portable –bound to one database pg_query(…) fast –optimised to database support all functionality non-standard interface significant code-rewriting to change database frameworks like Cake help

PEAR DB Library database independent abstraction layer provided as standard with PHP sits on top of DB client libraries code more portable to other databases supports only standard DB functionality runs slightly slower than specific extensions

Example <?php require_once ('DB.php'); $db = DB::connect $sql = "SELECT * FROM FREEZER"; $q = $db->query ($sql); while ($q->fetchInto($item)) {... } ?>

PHP with PEAR DB powerful approach current technology of choice for small to mid- size 3-tier systems easy to implement portable across different platforms specific extensions can optimise performance limited use for high-end applications –because of general PHP scaleability issues

database connectivity with JSP and servlets

JDBC Java API for Databases –packaged with Java Enterprise interacts with three major database architectures –relational main design focus of JDBC –object-oriented data and methods bundled together in a class hierarchy –object-relational

JDBC advantages –object to relational mapping –tables become objects with standard properties and methods –database independence –full Java support for distributed computing

JDBC driver types Type 1 –bridges to client libraries –requires client software example:JDBC-ODBC bridge Type 2 –native API drivers –JDBC driver calls native methods –native methods provided by database vendors –requires client software

JDBC driver types Type 3 generic client API uses sockets to call database-specific middleware most flexible can provide simultaneous access to multiple databases

JDBC driver types Type 4 database specific, but networked talk directly to database using sockets use proprietary network protocols almost never documented purchased directly from database vendors

Example public class Fridge { public static void main(String [] args) { String url = "jdbc:msql://fridge.com/fridge"; Connection db = null;... try { db = DriverManager.getConnection (url,"user","pass"); Statement sql = db.createStatement ();

Example String query = "SELECT * FROM FREEZER"; ResultSet r = sql.executeQuery (query); while (r.next()) { … // do some stuff } catch(Exception e){e.printStackTrace ();} try {db.close ();} catch(Exception e){e.printStackTrace ();} }

summary of JDBC integrates well with JSP/servelet programming full power of Java programming robust error and exception handling suitable for mid-to-high-end 3- and multi-tier systems –too sophisticated for simpler systems useful tools to ease development –IDEs: NetBeans, Eclipse –Jakarta Turbine

database connectivity with ASP

ADO ActiveX Data Objects provide an API for accessing databases use OLE DB, ODBC Windows platform specific ASP processor creates standard objects to manipulate and retrieve data –Command, Connection, Recordset, Record, Field, Error, Parameter, Property, Stream

Example <% Set db = Server.CreateObject ('ADODB.Connection') str = "driver=MySQL; ; uid='user'; pwd='pass'; database=Fridge" 'open the connection. db.Open str 'create a recordset Set r = Server.CreateObject ('ADODB.Recordset')... continued...

Example... continued... 'construct the SQL for the query sql = "SELECT * FROM FREEZER" 'get the data into the recordset r.Open sql, db... 'release resources Set r = Nothing Set db = Nothing %>

summary of ASP and ADO powerful set of tools platform specific (Windows) versioning incompatibilities –different versions of Windows –different versions of ADO difficult to use –improved under.NET framework not worth the effort for low-end systems –PHP a better choice

database connectivity with ColdFusion

ColdFusion database connection through CFQUERY tag –ODBC most databases standard functionality only –OLE DB (Windows only) Access and SQL Server as standard others available –Native drivers database specific database-specific extensions –not portable

CFQUERY syntax <CFQUERY NAME = "query_name" DATASOURCE = "datasource_name" DBTYPE = "dbtype" CONNECTSTRING = "connection_string" > SQL statements Accessed with

Example <CFQUERY NAME = "fridge_query" DATASOURCE = "Fridge" DBTYPE = "ODBC" CONNECTSTRING = "DRIVER=MicroSoft Access Driver (*.mdb);DBQ=D:\dbfiles\Fridge.mdb;FIL=MSAccess ;UID=user;PWD=pass" > SELECT * FROM FREEZER

summary of ColdFusion approach powerful tag-based DB interface no DB-specific knowledge required wide range of databases supported good for medium to high end systems data locking through CFLOCK