SlideShare uma empresa Scribd logo
1 de 37
DBMS & PROGRAMMING
LANGUAGE
Contents

   Object persistence
   Object serialization
   Using database
   Embedded SQL
   Database drivers
Object Persistence
   One of the most critical tasks that applications have to perform is
    to save and restore data

   Persistence is the storage of data from working memory so that
    it can be restored when the application is run again

   In object-oriented systems, there are several ways in which
    objects can be made persistent

   The choice of persistence method is an important part of the
    design of an application
Object Serialization
   Simple persistence method which provides a program the
    ability to read or write a whole object to and from a stream of
    bytes

   Allows Java objects to be encoded into a byte stream suitable
    for streaming to a file on disk or over a network

   The class must implement the Serializable interface
    (java.io.Serializable), which does not declare any methods,
    and have accessors and mutators for its attributes
Using Databases
   Most Client-Server applications use a RDBMS as their
    data store while using an object-oriented programming
    language for development

   Objects must be mapped to tables in the database and
    vice versa

   Applications generally require the use of SQL statements
    embedded in another programming language

   Impedance mismatch
   Goal of object-oriented design is to model a process
   Goal of relational database design is normalisation
   The mapping from objects to tables can be difficult if
    the model contains
     complex class structures

     large unstructured objects

     object inheritance

   The resulting tables may store data inefficiently, or
    access to data may be inefficient
   There are essentially three approaches which have been
    developed for the management of object storage in databases:

       the Object-Oriented Database Management System
        (OODBMS)
       the Object-Relational Database Management System
        (ORDBMS)
       Object Relational Mapping
EMBEDDED SQL
Interactive SQL
   SQL
•   SQL is a ‘non-procedural’ language
•   SQL specifies WHAT is required, not HOW this requirement
    is to be met.

   INTERACTIVE SQL is good for:
     –   defining database structure
     –   generating low-volume, ad hoc queries
     –   Prototyping

   INTERACTIVE SQL is not good for the more sophisticated
    applications for which a programming language with links to
    SQL might be better.
Embedded SQL
SQL can be embedded within procedural programming
languages. These language (sometimes referred to as 3GLs)
include C/C++, Cobol, Fortran, and Perl. Thus the embedded SQL
provides the 3GL with a way to manipulate a database,
supporting:

 •   highly customized applications
 •   background applications running without user intervention
 •   database manipulation which exceeds the abilities of simple
     SQL
 •   applications linking to Oracle packages, e.g. forms and
     reports
 •   applications which need customized window interfaces
Embedded SQL
   SQL statements placed within a program. The source program is
    called the host program, and the language in which it is written is
    called the host language.

   We can execute any SQL statement using embedded SQL
    statements just as if we were in SQL*Plus.
        CREATE, ALTER and DROP database tables
        SELECT, INSERT, UPDATE and DELETE rows of data
        COMMIT transactions (make any changes to the database
         permanent)
Embedded SQL Statements
   Embedded SQL statements incorporate DDL, DML, and transaction
    control statements within a procedural language program.

   They are used with the Oracle pre-compilers, e.g. Pro*C.

   Embedded SQL statements enable to
      define, allocate, and release cursors

      declare a database name and connect to Oracle

      assign variable names

      initialize descriptors

      specify how error and warning conditions are handled

      parse and execute SQL statements

      retrieve data from the database
Executable and Declarative Statements
   Embedded SQL includes all the interactive SQL statements plus others
    that allow to transfer data between Oracle and a host program. There are
    two types of embedded SQL statements:

   Executable:
     used to connect to Oracle, to define, query and manipulate Oracle data,

      to control access to Oracle data and to process transactions. They can
      be placed wherever host-language executable statements can be
      placed.

   Declarative:
     do not operate on SQL data. Use them to declare Oracle objects,

      communication areas and SQL variables which will be used by Oracle
      and host program. They can be placed wherever host-language
      declarations can be placed.
SQL Precompiler

Precompilers are used to translate SQL
statements embedded in a host language
                                              E dito r           ho s t p ro g ra m + e m be dde d S Q L
into DBMS library calls which can be
implemented in the host language.
                                            P re co m pi l e r
In recent times, the database-program
link is shown in the program much more
                                                                 ho s t p ro g ra m + tra ns la te d S Q L
explicitly, and the need for precompilers
has been greatly reduced.
                                             C o m pil e r
                                                                 o b j e ct (bi n a ry ) pro g ra m
                                              L ink e r                  D B M S a nd o the r l i b ra ri e s
                                                                 e x e cuta bl e pro g ra m
Cursors - SELECT many rows
   A cursor provides a pointer to a single row in the result of a
    selection query (which may return may rows)

   One row at a time is accessed through the cursor, which is moved
    to the next row before each data transfer

   The columns of that one row are ‘fetched’ into the program variables
    which can then be manipulated in the normal way by the host
    program.

   A cursor can also be used to update values in tables if it is linked to
    an INSERT SQL command rather than a SELECT query.
   Cursors provide a means of integrating traditional 3GL
    procedural languages and databases by enabling row-at-a-time
    access.

   Languages such as Visual Basic and Visual C++ also have build-
    in statements that enable this type of processing with a
    dedicated database, like that provided by MS-Access
.
   Java has a well-defined interface to enable easy access to
    databases through a Database Connectivity library - JDBC.

   Perl makes use of the DBI standard, which is fast becoming the
    main contender to ODBC.
Database Drivers

   Think of a database as just another device connected to your
    computer

   Like other devices it has a driver program to relieves you of
    having to do low level programming to use the database

   The driver provides you with a high level API to the database
Database middleware
   ODBC – Open Database Connectivity - most DB vendors
    support this

   OLE-DB - Microsoft enhancement of ODBC

   JDBC – Java Database Connectivity - Special Java classes
    that allow Java applications/applets to connect to databases

   CORBA – Common Object Request Broker Architecture –
    specification of object-oriented middleware

   DCOM – Microsoft’s version of CORBA – not as robust as
    CORBA over multiple platforms
Middleware
   Software which allows an application to interoperate with
    other software, without requiring the user to understand
    and code the low-level operations required to achieve
    interoperability

   With Synchronous systems, the requesting system waits
    for a response to the request in real time

   Asynchronous systems send a request but do not wait for
    a response in real time – the response is accepted
    whenever it is received .

       The “glue” that holds client/server applications together
ODBC – OPEN DATABASE
CONNECTIVITY
What is ODBC ?

    Open Database Connectivity (ODBC) is an API that provides
     a common language for application programs to access and
     process SQL databases independent of the particular
     RDBMS that is accessed.

ODBC driver needs the following :
    1.   Back-end server name
    2.   Database name
    3.   User id and password
ODBC Architecture

              Client does not need
              to know anything
              about the DBMS
                     Application Program
                     Interface (API) provides
                     common interface to all
                     DBMSs




       Each DBMS has its own ODBC-compliant driver
   Client application requests that a connection is established with a
    data source

   Driver manager identifies appropriate ODBC driver to use

   Driver selected will process the requests received from the client
    and submit queries to the RDBMS in the required version of SQL
   Java Database Connectivity (JDBC) is similar to ODBC – built
    specifically for Java applications
DSN: Data Source Name
   All database connections begin with a DSN
   Named database configuration
   Three types:
     User DSN
     System DSN

     File DSN

   Win 95/98 only understand User and File
   When used as a CGI/ASP script with a web server always use
    System DSN!
Establish a Connection
•   Create a new Win32::ODBC object:
        $db = new Win32::ODBC( "My DSN" );
•   The DSN can either be the name of a DSN or it can be a
    full connect string:
    – “My DSN”

    – “DSN=My DSN;UID=Foo;PWD=Bar”

•   If the DSN passed in is really a Win32::ODBC object then
    that object is “cloned”
        $db2 = new Win32::ODBC( $db );
    –   $db2 is identical to $db.
    –   Some database systems do not like such clones.
Executing SQL Statement
   Submit a text based SQL query


        $Result = $db->Sql( “SELECT * FROM Foo” );

   This is the only method call which returns a non-false value upon
    failure
       Returns error number (ODBC driver specific; not really
        valuable)
       Call $db->Error() for more error details
Close Connection

   To close the database connection call Close()


                        $db->Close();
JDBC –
Java DataBase Connectivity
What is JDBC?
   “An API that lets you access virtually any tabular data
    source from the Java programming language”

   JDBC is oriented towards relational database.
JDBC Architecture
Basic steps to use
a database in Java

     1.Establish a connection
     2.Create JDBC Statements
     3.Execute SQL Statements
     4.GET ResultSet
     5.Close connections
Establish a connection
   import java.sql.*;
   Load the vendor specific driver
    Class.forName("oracle.jdbc.driver.OracleDriver");
         Dynamically loads a driver class, for Oracle database
   Make the connection
    Connection con =
    DriverManager.getConnection( "jdbc:oracle:thin:@oracle-
    prod:1521:OPROD", username, passwd);
         Establishes connection to database by obtaining
          a Connection object
Executing SQL Statements

   We can run any type of query again database to
    perform database operatons.

ResultSet res = st.executeQuery("SELECT * FROM FOO" );
Getting Result
   In this step we receives the result of execute statement. In this
    case we will fetch the employees records from the recordset
    object and show on the console.

     while (res.next()) {
     String FOOName = res.getIn( " FOO_name " );
     System.out.println( FOOName );
     }
Close connection
   Finally it is necessary to disconnect from the database and
    release resources being used. If you don’t close the connection
    then in the production environment your application will fail due
    to hanging database connections.



                         con.close();
Integrating Programming Languages &
Databases: What's the Problem??
THANK YOU 

Mais conteúdo relacionado

Mais procurados (19)

Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
jdbc document
jdbc documentjdbc document
jdbc document
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Model
 
Jdbc
JdbcJdbc
Jdbc
 
Sql server difference faqs- 6
Sql server difference faqs- 6Sql server difference faqs- 6
Sql server difference faqs- 6
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc driver types
Jdbc driver typesJdbc driver types
Jdbc driver types
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
JDBC Driver Types
JDBC Driver TypesJDBC Driver Types
JDBC Driver Types
 
Java database programming with jdbc
Java database programming with jdbcJava database programming with jdbc
Java database programming with jdbc
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
 
JDBC Architecture and Drivers
JDBC Architecture and DriversJDBC Architecture and Drivers
JDBC Architecture and Drivers
 
Jdbc_ravi_2016
Jdbc_ravi_2016Jdbc_ravi_2016
Jdbc_ravi_2016
 
jdbc
jdbcjdbc
jdbc
 
Rajesh jdbc
Rajesh   jdbcRajesh   jdbc
Rajesh jdbc
 

Destaque

Java event processing model in c# and java
Java  event processing model in c# and javaJava  event processing model in c# and java
Java event processing model in c# and javaTech_MX
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developersllangit
 
Spatialware_2_Sql08
Spatialware_2_Sql08Spatialware_2_Sql08
Spatialware_2_Sql08Mike Osbourn
 
AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...
AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...
AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...Andrey Gershun
 
Transact sql data definition language - ddl- reference
Transact sql data definition language - ddl- referenceTransact sql data definition language - ddl- reference
Transact sql data definition language - ddl- referenceSteve Xu
 
5 tsssisu sql_server_2012
5 tsssisu sql_server_20125 tsssisu sql_server_2012
5 tsssisu sql_server_2012Steve Xu
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developersllangit
 
Css introduction
Css introductionCss introduction
Css introductionSridhar P
 
Multi-thematic spatial databases
Multi-thematic spatial databasesMulti-thematic spatial databases
Multi-thematic spatial databasesConor Mc Elhinney
 
High Performance Front-End Development
High Performance Front-End DevelopmentHigh Performance Front-End Development
High Performance Front-End Developmentdrywallbmb
 
Alasql.js - SQL сервер на JavaScript
Alasql.js - SQL сервер на JavaScriptAlasql.js - SQL сервер на JavaScript
Alasql.js - SQL сервер на JavaScriptAndrey Gershun
 
X query language reference
X query language referenceX query language reference
X query language referenceSteve Xu
 

Destaque (20)

Java event processing model in c# and java
Java  event processing model in c# and javaJava  event processing model in c# and java
Java event processing model in c# and java
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developers
 
Module07
Module07Module07
Module07
 
Module05
Module05Module05
Module05
 
Spatialware_2_Sql08
Spatialware_2_Sql08Spatialware_2_Sql08
Spatialware_2_Sql08
 
Module06
Module06Module06
Module06
 
AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...
AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...
AlaSQL библиотека для обработки JavaScript данных (презентация для ForntEnd 2...
 
Transact sql data definition language - ddl- reference
Transact sql data definition language - ddl- referenceTransact sql data definition language - ddl- reference
Transact sql data definition language - ddl- reference
 
5 tsssisu sql_server_2012
5 tsssisu sql_server_20125 tsssisu sql_server_2012
5 tsssisu sql_server_2012
 
SQL Server 2008 Spatial Data - Getting Started
SQL Server 2008 Spatial Data - Getting StartedSQL Server 2008 Spatial Data - Getting Started
SQL Server 2008 Spatial Data - Getting Started
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developers
 
Module01
Module01Module01
Module01
 
Css introduction
Css introductionCss introduction
Css introduction
 
Multi-thematic spatial databases
Multi-thematic spatial databasesMulti-thematic spatial databases
Multi-thematic spatial databases
 
Module08
Module08Module08
Module08
 
Module02
Module02Module02
Module02
 
High Performance Front-End Development
High Performance Front-End DevelopmentHigh Performance Front-End Development
High Performance Front-End Development
 
Alasql.js - SQL сервер на JavaScript
Alasql.js - SQL сервер на JavaScriptAlasql.js - SQL сервер на JavaScript
Alasql.js - SQL сервер на JavaScript
 
Module04
Module04Module04
Module04
 
X query language reference
X query language referenceX query language reference
X query language reference
 

Semelhante a Dbms & prog lang

SQL Training courses.pptx
SQL Training courses.pptxSQL Training courses.pptx
SQL Training courses.pptxirfanakram32
 
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming LanguagesS.Shayan Daneshvar
 
SQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfSQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfNiravPanchal50
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05JONDHLEPOLY
 
Database application developer's guide
Database application developer's guideDatabase application developer's guide
Database application developer's guideSudar's Juba
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggetsVirtual Nuggets
 
System i - DDL vs DDS Presentation
System i - DDL vs DDS PresentationSystem i - DDL vs DDS Presentation
System i - DDL vs DDS PresentationChuck Walker
 
Advanced database protocols
Advanced database protocolsAdvanced database protocols
Advanced database protocolsHitesh Mohapatra
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectorsPhaniu
 
Mule database-connectors
Mule  database-connectorsMule  database-connectors
Mule database-connectorsD.Rajesh Kumar
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectorsirfan1008
 

Semelhante a Dbms & prog lang (20)

Db_05.ppt
Db_05.pptDb_05.ppt
Db_05.ppt
 
Database
DatabaseDatabase
Database
 
Microsoft data access components
Microsoft data access componentsMicrosoft data access components
Microsoft data access components
 
Oracle Intro.ppt
Oracle Intro.pptOracle Intro.ppt
Oracle Intro.ppt
 
SQL Training courses.pptx
SQL Training courses.pptxSQL Training courses.pptx
SQL Training courses.pptx
 
Chapter02
Chapter02Chapter02
Chapter02
 
Sql server
Sql serverSql server
Sql server
 
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming Languages
 
SQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfSQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdf
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Database application developer's guide
Database application developer's guideDatabase application developer's guide
Database application developer's guide
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
 
System i - DDL vs DDS Presentation
System i - DDL vs DDS PresentationSystem i - DDL vs DDS Presentation
System i - DDL vs DDS Presentation
 
INTRODUCTION TO DATABASE
INTRODUCTION TO DATABASEINTRODUCTION TO DATABASE
INTRODUCTION TO DATABASE
 
Advanced database protocols
Advanced database protocolsAdvanced database protocols
Advanced database protocols
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectors
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectors
 
Mule database-connectors
Mule  database-connectorsMule  database-connectors
Mule database-connectors
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectors
 
14 db system
14 db system14 db system
14 db system
 

Mais de Tech_MX

Virtual base class
Virtual base classVirtual base class
Virtual base classTech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimationTech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
String & its application
String & its applicationString & its application
String & its applicationTech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applicationsTech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pcTech_MX
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbmsTech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbmsTech_MX
 

Mais de Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Uid
UidUid
Uid
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
String & its application
String & its applicationString & its application
String & its application
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Spss
SpssSpss
Spss
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
 
Set data structure
Set data structure Set data structure
Set data structure
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Parsing
ParsingParsing
Parsing
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
 
More on Lex
More on LexMore on Lex
More on Lex
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 

Último

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Último (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Dbms & prog lang

  • 2. Contents  Object persistence  Object serialization  Using database  Embedded SQL  Database drivers
  • 3. Object Persistence  One of the most critical tasks that applications have to perform is to save and restore data  Persistence is the storage of data from working memory so that it can be restored when the application is run again  In object-oriented systems, there are several ways in which objects can be made persistent  The choice of persistence method is an important part of the design of an application
  • 4. Object Serialization  Simple persistence method which provides a program the ability to read or write a whole object to and from a stream of bytes  Allows Java objects to be encoded into a byte stream suitable for streaming to a file on disk or over a network  The class must implement the Serializable interface (java.io.Serializable), which does not declare any methods, and have accessors and mutators for its attributes
  • 5. Using Databases  Most Client-Server applications use a RDBMS as their data store while using an object-oriented programming language for development  Objects must be mapped to tables in the database and vice versa  Applications generally require the use of SQL statements embedded in another programming language  Impedance mismatch
  • 6. Goal of object-oriented design is to model a process  Goal of relational database design is normalisation  The mapping from objects to tables can be difficult if the model contains  complex class structures  large unstructured objects  object inheritance  The resulting tables may store data inefficiently, or access to data may be inefficient
  • 7. There are essentially three approaches which have been developed for the management of object storage in databases:  the Object-Oriented Database Management System (OODBMS)  the Object-Relational Database Management System (ORDBMS)  Object Relational Mapping
  • 9. Interactive SQL  SQL • SQL is a ‘non-procedural’ language • SQL specifies WHAT is required, not HOW this requirement is to be met.  INTERACTIVE SQL is good for: – defining database structure – generating low-volume, ad hoc queries – Prototyping  INTERACTIVE SQL is not good for the more sophisticated applications for which a programming language with links to SQL might be better.
  • 10. Embedded SQL SQL can be embedded within procedural programming languages. These language (sometimes referred to as 3GLs) include C/C++, Cobol, Fortran, and Perl. Thus the embedded SQL provides the 3GL with a way to manipulate a database, supporting: • highly customized applications • background applications running without user intervention • database manipulation which exceeds the abilities of simple SQL • applications linking to Oracle packages, e.g. forms and reports • applications which need customized window interfaces
  • 11. Embedded SQL  SQL statements placed within a program. The source program is called the host program, and the language in which it is written is called the host language.  We can execute any SQL statement using embedded SQL statements just as if we were in SQL*Plus.  CREATE, ALTER and DROP database tables  SELECT, INSERT, UPDATE and DELETE rows of data  COMMIT transactions (make any changes to the database permanent)
  • 12. Embedded SQL Statements  Embedded SQL statements incorporate DDL, DML, and transaction control statements within a procedural language program.  They are used with the Oracle pre-compilers, e.g. Pro*C.  Embedded SQL statements enable to  define, allocate, and release cursors  declare a database name and connect to Oracle  assign variable names  initialize descriptors  specify how error and warning conditions are handled  parse and execute SQL statements  retrieve data from the database
  • 13. Executable and Declarative Statements  Embedded SQL includes all the interactive SQL statements plus others that allow to transfer data between Oracle and a host program. There are two types of embedded SQL statements:  Executable:  used to connect to Oracle, to define, query and manipulate Oracle data, to control access to Oracle data and to process transactions. They can be placed wherever host-language executable statements can be placed.  Declarative:  do not operate on SQL data. Use them to declare Oracle objects, communication areas and SQL variables which will be used by Oracle and host program. They can be placed wherever host-language declarations can be placed.
  • 14. SQL Precompiler Precompilers are used to translate SQL statements embedded in a host language E dito r ho s t p ro g ra m + e m be dde d S Q L into DBMS library calls which can be implemented in the host language. P re co m pi l e r In recent times, the database-program link is shown in the program much more ho s t p ro g ra m + tra ns la te d S Q L explicitly, and the need for precompilers has been greatly reduced. C o m pil e r o b j e ct (bi n a ry ) pro g ra m L ink e r D B M S a nd o the r l i b ra ri e s e x e cuta bl e pro g ra m
  • 15. Cursors - SELECT many rows  A cursor provides a pointer to a single row in the result of a selection query (which may return may rows)  One row at a time is accessed through the cursor, which is moved to the next row before each data transfer  The columns of that one row are ‘fetched’ into the program variables which can then be manipulated in the normal way by the host program.  A cursor can also be used to update values in tables if it is linked to an INSERT SQL command rather than a SELECT query.
  • 16. Cursors provide a means of integrating traditional 3GL procedural languages and databases by enabling row-at-a-time access.  Languages such as Visual Basic and Visual C++ also have build- in statements that enable this type of processing with a dedicated database, like that provided by MS-Access .  Java has a well-defined interface to enable easy access to databases through a Database Connectivity library - JDBC.  Perl makes use of the DBI standard, which is fast becoming the main contender to ODBC.
  • 17. Database Drivers  Think of a database as just another device connected to your computer  Like other devices it has a driver program to relieves you of having to do low level programming to use the database  The driver provides you with a high level API to the database
  • 18. Database middleware  ODBC – Open Database Connectivity - most DB vendors support this  OLE-DB - Microsoft enhancement of ODBC  JDBC – Java Database Connectivity - Special Java classes that allow Java applications/applets to connect to databases  CORBA – Common Object Request Broker Architecture – specification of object-oriented middleware  DCOM – Microsoft’s version of CORBA – not as robust as CORBA over multiple platforms
  • 19. Middleware  Software which allows an application to interoperate with other software, without requiring the user to understand and code the low-level operations required to achieve interoperability  With Synchronous systems, the requesting system waits for a response to the request in real time  Asynchronous systems send a request but do not wait for a response in real time – the response is accepted whenever it is received . The “glue” that holds client/server applications together
  • 20. ODBC – OPEN DATABASE CONNECTIVITY
  • 21. What is ODBC ?  Open Database Connectivity (ODBC) is an API that provides a common language for application programs to access and process SQL databases independent of the particular RDBMS that is accessed. ODBC driver needs the following : 1. Back-end server name 2. Database name 3. User id and password
  • 22. ODBC Architecture Client does not need to know anything about the DBMS Application Program Interface (API) provides common interface to all DBMSs Each DBMS has its own ODBC-compliant driver
  • 23. Client application requests that a connection is established with a data source  Driver manager identifies appropriate ODBC driver to use  Driver selected will process the requests received from the client and submit queries to the RDBMS in the required version of SQL  Java Database Connectivity (JDBC) is similar to ODBC – built specifically for Java applications
  • 24. DSN: Data Source Name  All database connections begin with a DSN  Named database configuration  Three types:  User DSN  System DSN  File DSN  Win 95/98 only understand User and File  When used as a CGI/ASP script with a web server always use System DSN!
  • 25. Establish a Connection • Create a new Win32::ODBC object:  $db = new Win32::ODBC( "My DSN" ); • The DSN can either be the name of a DSN or it can be a full connect string: – “My DSN” – “DSN=My DSN;UID=Foo;PWD=Bar” • If the DSN passed in is really a Win32::ODBC object then that object is “cloned”  $db2 = new Win32::ODBC( $db ); – $db2 is identical to $db. – Some database systems do not like such clones.
  • 26. Executing SQL Statement  Submit a text based SQL query $Result = $db->Sql( “SELECT * FROM Foo” );  This is the only method call which returns a non-false value upon failure  Returns error number (ODBC driver specific; not really valuable)  Call $db->Error() for more error details
  • 27. Close Connection  To close the database connection call Close() $db->Close();
  • 28. JDBC – Java DataBase Connectivity
  • 29. What is JDBC?  “An API that lets you access virtually any tabular data source from the Java programming language”  JDBC is oriented towards relational database.
  • 31. Basic steps to use a database in Java 1.Establish a connection 2.Create JDBC Statements 3.Execute SQL Statements 4.GET ResultSet 5.Close connections
  • 32. Establish a connection  import java.sql.*;  Load the vendor specific driver Class.forName("oracle.jdbc.driver.OracleDriver");  Dynamically loads a driver class, for Oracle database  Make the connection Connection con = DriverManager.getConnection( "jdbc:oracle:thin:@oracle- prod:1521:OPROD", username, passwd);  Establishes connection to database by obtaining a Connection object
  • 33. Executing SQL Statements  We can run any type of query again database to perform database operatons. ResultSet res = st.executeQuery("SELECT * FROM FOO" );
  • 34. Getting Result  In this step we receives the result of execute statement. In this case we will fetch the employees records from the recordset object and show on the console. while (res.next()) { String FOOName = res.getIn( " FOO_name " ); System.out.println( FOOName ); }
  • 35. Close connection  Finally it is necessary to disconnect from the database and release resources being used. If you don’t close the connection then in the production environment your application will fail due to hanging database connections. con.close();
  • 36. Integrating Programming Languages & Databases: What's the Problem??