Java E-Commerce Martin Cooke,
|
|
- Nathaniel Gaines
- 6 years ago
- Views:
Transcription
1 Java E-Commerce Martin Cooke, Java Database Connectivity (JDBC) Plan Java database connectivity API (JDBC) Examples Advanced features JNDI JDBC 13/02/2004 Java E-Commerce Martin Cooke, Design goals ODBC JDBC architecture Build on the simplicity and portability of SQL Simple to use for non-database programmers queries return Java objects access problems return as exceptions Hide specific database details from programmer Generalise to any tabular data source Learn from (and avoid the mistakes of) ODBC Open database connectivity Open = so long as you operate within Windows :-) C API which doesn t translate well into Java Overly complex design from programmers perspective Complete failure to transit outside Windows environment MySQL Oracle Postgres 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
2 Java E-Commerce Martin Cooke, JDBC architecture JDBC architecture How-to JDBC defines a set of interfaces Vendors implement these for their database engine Known as a JDBC driver MySQL JDBC Postgres Oracle JDBC defines a set of interfaces Vendors implement these for their database engine Known as a JDBC driver Easy to switch vendors without changing a line of code (simple an entry in a configuration file choosing a different driver) Can develop on a toy system like MS Access then migrate to industrialstrength later with ease App 1 App 2 JDBC MySQL Oracle Postgres Acquire a (free) relational database engine postgresql MySQL msql instantdb Acquire a (free) JDBC driver for the chosen engine See list at industry.java.sun.com/products/jdbc/drivers 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, MySQL Some factoids Developed from 1995 by Michael Widenius in Sweden Described as one of the hottest grass roots software projects since Linux Ran on estimated 500,000 servers in 1999 and has grown significantly since Available for most platforms Industrial-strength: fast and stable Extensively documented Available in DCS Accessing your data in 4 steps 1: load the driver Connection con = null; Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection ("jdbc:mysql://hazel/studs", mpc",""); Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery("select name FROM student"); while (rs.next()) System.out.println(rs.getString(1)); catch (SQLException e) { System.out.println("SQLException: " + e.getmessage()); catch (Exception e) { System.err.println("Unable to load driver."); e.printstacktrace(); 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
3 Java E-Commerce Martin Cooke, : get a connection 3: execute a query 4: do something with the results Connection con = null; Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection ("jdbc:mysql://hazel/studs", mpc",""); Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery("select name FROM student"); while (rs.next()) System.out.println(rs.getString(1)); catch (SQLException e) { System.out.println("SQLException: " + e.getmessage()); catch (Exception e) { System.err.println("Unable to load driver."); e.printstacktrace(); Connection con = null; Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection ("jdbc:mysql://hazel/studs", mpc",""); Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery("select name FROM student"); while (rs.next()) System.out.println(rs.getString(1)); catch (SQLException e) { System.out.println("SQLException: " + e.getmessage()); catch (Exception e) { System.err.println("Unable to load driver."); e.printstacktrace(); Connection con = null; Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection ("jdbc:mysql://hazel/studs", mpc",""); Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery("select name FROM student"); while (rs.next()) System.out.println(rs.getString(1)); catch (SQLException e) { System.out.println("SQLException: " + e.getmessage()); catch (Exception e) { System.err.println("Unable to load driver."); e.printstacktrace(); 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, Tidying up a precious resource Key JDBC classes More on statements rs.close(); stmt.close(); finally { if (con!= null) con.close(); DriverManager Connection Statement ResultSet Used, amongst other things, to obtain connection Logical connection used to send SQL to the database SQL statement Data returned by a query For queries public ResultSet executequery(string sql) For updates public int executeupdate(string sql) (returns number of rows affected) When you don t know which public boolean execute(string sql) 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
4 Java E-Commerce Martin Cooke, More on result sets More on result sets Provides access to database queries one row at a time Moves through sequentially, once only ResultSet object is a reference, since actual result set could be very large Methods for getting common data types getdate() getint() getstring() Can use getobject() if you don t know the type JDBC 2.0 provides scrollable result sets (later) Other features of JDBC 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, Other features of JDBC Meta data Prepared statements Transactions Scrollable result sets Storing binary data Meta data Suppose we don t know how many columns will be returned by a query; or what the columns are called Use ResultSetMetaData class ResultSetMetaData rsmd = rs.getmetadata() rsmd.getcolumncount(i) rsmd.getcolumnlabel(i) Prepared statements Like an ordinary Statement in that it represents an SQL statement Is precompiled by database for faster execution Can be modified after compilation PreparedStatement pstmt = con.preparestatement( SELECT name FROM student WHERE id=? ); pstmt.clearparameters(); pstmt.setint(1,somevalue); ResultSet rs = pstmt.executequery(); 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
5 Java E-Commerce Martin Cooke, Prepared statements contd Transactions Transaction issues Useful when need to run same (parameterised) statement many times Also useful when there are lots of parameters to fill in, to avoid huge and messy SQL strings Also useful because of the quotes problem: INSERT INTO student VALUES (null, Basil d Oliveira ) Either remember to escape quotes with \ or Use prepared statement Classic example: transferring money between accounts: Debit account 1, credit account 2 What if system fails between the two? Less problematic in some applications reading incorrect data Dirty reads non-repeatable reads Phantom reads transaction 1 can see uncommitted changes from transaction 2 1. transaction 1 reads a row 2. transaction 2 alters the row 3. transaction rereads row, getting different values Changes in another transaction cause new rows to match your WHERE clause 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, Transaction isolation Transactions in JDBC MySQL support for transactions Transaction isolation defines the visibility of one transaction on another JDBC specifies 5 levels of isolation weakest: TRANSACTION_NONE (no support for transactions) stongest: TRANSACTION_SERIALIZABLE (full isolation) Typically, tradeoff between isolation and speed Full isolation is costly and often OTT 13/02/2004 Java E-Commerce Martin Cooke, con.setautocommit(false); // defaults to true s = con.createstatement(); s.executeupdate( INSERT ); s.close(); s = con.createstatement(); s.executeupdate( INSERT ); con.commit(); s.close(); catch (SQLException e) { if (con!= null) { con.rollback(); catch (SQLException e) { 13/02/2004 Java E-Commerce Martin Cooke, Yes, since version Done via BerkeleyDB Simply add table type at table create time: CREATE TABLE student ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(4), SSID INT DEFAULT 0 ) TYPE=BDB; 13/02/2004 Java E-Commerce Martin Cooke,
6 Java E-Commerce Martin Cooke, Scrollable result sets Storage/retrieval of large/binary data Binary and character large objects Added in JDBC 2.0 Allows in-place modification of result sets and more control of the result set cursor Can be inefficient for some database drivers Large text strings (eg entire books), up to several gigs Binary objects (eg GIF images, sound files) LONGVARCHAR BINARY VARBINARY LONGVARBINARY getasciistream() getbinarystream() Large text strings (eg entire books), up to several gigs Binary objects (eg GIF images, sound files) LONGVARCHAR CLOB BINARY VARBINARY LONGVARBINARY BLOB getasciistream() getclob() getbinarystream() getblob() Can be source of problems due to drivers Sometimes have small maximum sizes Underlying object is often read all at once New in JDBC 2.0 Return streams, so data read at your leisure Not so simple to store 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, Connection bottlenecks Solutions Connection pooling Creating a connection is a very expensive operation (several seconds, typically) The open connection, talk to database, close connection model is simply infeasible for typical e-commerce applications Singleton: open a single connection when webapp inits and use it for all DB operations + guaranteed to be thread safe, but consequently doesn t avoid performance bottleneck + easy and fast for small sites - doesn t exploit database support for simultaneous connections 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
7 Java E-Commerce Martin Cooke, Solutions Solutions Connection pool how-to: 1 Singleton: open a single connection when webapp inits and use it for all DB operations Connection pool: open a pool of connections on init and dish them out as needed + guaranteed to be thread safe, but consequently doesn t avoid performance bottleneck + easy and fast for small sites - doesn t exploit database support for simultaneous connections + supported in JDBC easy + fast + scales to very large sites Singleton: open a single connection when webapp inits and use it for all DB operations Connection pool: open a pool of connections on init and dish them out as needed Session connections: allocate a connection for each active user (session) + guaranteed to be thread safe, but consequently doesn t avoid performance bottleneck + easy and fast for small sites - doesn t exploit database support for simultaneous connections + supported in JDBC easy + fast + scales to very large sites + very fast + quite easy to implement - not good for sites with very high traffic Use 3rd party connection pool class com.javaexchange.dbconnectionbroker mybroker = new DbConnectionBroker (driver,dburl,user,pwd, mincs,maxcs,logfile,maxconnecttime); conn = mybroker.getconnection(); mybroker.freeconnection(conn); Not necessarily portable since doesn t follow API 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, Connection pool how-to: 2 DataSource DataSource Use JDBC 2.0 Optional Package (ie find a driver that supports it) Feb 2002 version of mm driver Several advantages other than pooling Abstracts most connection details Supports distributed transactions Transactions which span more than one datasource eg buy book, update book db, credit card db, Not norm yet, but likely to be soon because of vendor-independence engendered by JDBC Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup( jdbc/mydb ); A context is a JNDI concept (see next slide) Use context to lookup a DataSource Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup( jdbc/mydb ); Connection con = ds.getconnection(user,pwd); // use connection con.close() A context is a JNDI concept (see next slide) Use context to lookup a DataSource Get connection (from pool) Use it Close it (returns it to the pool) 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
8 Java E-Commerce Martin Cooke, JNDI JNDI JNDI Java Naming and Directory Interface Enterprise-level API used to provide uniform access to services: File systems Databases Distributed objects (later) A naming service matches things such as printers, files, file servers, to names A naming service matches things such as printers, files, file servers, to names A directory service adds attributes to the names (eg colour printer, database driver class) Source: Source: 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, Why JNDI? Uniform access to existing & diverse naming services: COS (Common Object Services) Naming: The naming service for CORBA applications; DNS (Domain Name System): The Internet's naming service; maps people-friendly names (such as into computer-friendly IP (Internet Protocol) addresses in dotted-quad notation ( ). LDAP (Lightweight Directory Access Protocol): Developed by the University of Michigan; as its name implies, it is a lightweight version of DAP (Directory Access Protocol), which in turn is part of X.500, a standard for network directory services. NIS (Network Information System) and NIS+: Network naming services developed by Sun Microsystems. Both allow users to access files and applications on any host with a single ID and password. Source: JNDI benefits Virtual: uses simple URLs and hierarchical structure Dynamic: can configure services at runtime Enables finding by logical names rather than by knowing the paths DataSource ds = (DataSource) ctx.lookup( jdbc/mydb ); JNDI how-to Objects (such as DataSource) have to be bound to the JNDI service before they can be accessed by clients Usually done with a GUI tool; one-off process Can be done programmatically: Context ctx = new InitialContext(); ds = new MysqlDataSource(); ds.setservername("localhost"); ds.setdatabasename("test"); ctx.bind( jdbc/test", ds); ctx.close(); Don t forget to import java.naming.* 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
9 Java E-Commerce Martin Cooke, Book Online documents Resources Reese (2000) JDBC and Java (2 nd ed), O Reilly, JNDI articles 13/02/2004 Java E-Commerce Martin Cooke, /02/2004 Java E-Commerce Martin Cooke,
Database Programming Overview. COSC 304 Introduction to Database Systems. Database Programming. JDBC Interfaces. JDBC Overview
COSC 304 Introduction to Database Systems Database Programming Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Database Programming Overview Most user interaction with
More informationDatabases 2012 Embedded SQL
Databases 2012 Christian S. Jensen Computer Science, Aarhus University SQL is rarely written as ad-hoc queries using the generic SQL interface The typical scenario: client server database SQL is embedded
More informationJDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection.
JDBC PROGRAMMING JDBC JDBC Java DataBase Connectivity Useful for database driven applications Standard API for accessing relational databases Compatible with wide range of databases Current Version JDBC
More informationIntroduction to JDBC. JDBC: Java Database Connectivity. Why Access a Database with Java? Compilation. Six Steps. Packages to Import
Introduction to JDBC JDBC: Java Database Connectivity JDBC is used for accessing databases from Java applications Information is transferred from relations to objects and vice-versa databases optimized
More informationLogging and Recovery. 444 Section, April 23, 2009
Logging and Recovery 444 Section, April 23, 2009 Reminders Project 2 out: Due Wednesday, Nov. 4, 2009 Homework 1: Due Wednesday, Oct. 28, 2009 Outline Project 2: JDBC ACID: Recovery Undo, Redo logging
More informationSQL: Programming Midterm in class next Thursday (October 5)
Announcements (September 28) 2 Homework #1 graded Homework #2 due today Solution available this weekend SQL: Programming Midterm in class next Thursday (October 5) Open book, open notes Format similar
More informationJAVA AND DATABASES. Summer 2018
JAVA AND DATABASES Summer 2018 JDBC JDBC (Java Database Connectivity) an API for working with databases in Java (works with any tabular data, but focuses on relational databases) Works with 3 basic actions:
More informationCSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige
CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft
More informationYou write standard JDBC API application and plug in the appropriate JDBC driver for the database the you want to use. Java applet, app or servlets
JDBC Stands for Java Database Connectivity, is an API specification that defines the following: 1. How to interact with database/data-source from Java applets, apps, servlets 2. How to use JDBC drivers
More informationCyrus Shahabi Computer Science Department University of Southern California C. Shahabi
Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing
More informationApplication Programming for Relational Databases
Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing
More informationJava Database Connectivity
Java Database Connectivity PROGRAMMING Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda PreparedStatement
More informationKyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation
Kyle Brown Knowledge Systems Corporation 1 What is the JDBC? What other persistence mechanisms are available? What facilities does it offer? How is it used? 2 JDBC is the Java DataBase Connectivity specification
More informationJDBC drivers are divided into four types or levels. The different types of jdbc drivers are:
How many types of JDBC Drivers are present and what are they? JDBC drivers are divided into four types or levels. The different types of jdbc drivers are: Type 1: JDBC-ODBC Bridge driver (Bridge) Type
More informationDatabase Application Development
Database Application Development Linda Wu (CMPT 354 2004-2) Topics SQL in application code Embedded SQL JDBC SQLJ Stored procedures Chapter 6 CMPT 354 2004-2 2 SQL in Application Code SQL commands can
More informationERwin and JDBC. Mar. 6, 2007 Myoung Ho Kim
ERwin and JDBC Mar. 6, 2007 Myoung Ho Kim ERwin ERwin a popular commercial ER modeling tool» other tools: Dia (open source), Visio, ConceptDraw, etc. supports database schema generation 2 ERwin UI 3 Data
More informatione-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text
e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text Learning Objectives This module gives an introduction about Java Database
More informationSQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL.
SQL: Programming CPS 116 Introduction to Database Systems Announcements (September 25) 2 Homework #2 due this Thursday Submit to Yi not through Jun s office door Solution available this weekend No class
More informationJDBC 3.0. Java Database Connectivity. 1 Java
JDBC 3.0 Database Connectivity 1 Contents 1 JDBC API 2 JDBC Architecture 3 Steps to code 4 Code 5 How to configure the DSN for ODBC Driver for MS-Access 6 Driver Types 7 JDBC-ODBC Bridge 8 Disadvantages
More informationEnterprise Systems. Lecture 02: JDBC. Behzad BORDBAR
Enterprise Systems Lecture 02: JDBC Behzad BORDBAR 22 Contents Running example Sample code for beginners Properties to configure Statements and ResultSet Pitfalls of using ResultSet getobject() vs. getxxx()
More informationQuestions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers.
Q.1) What is, in terms of JDBC, a DataSource? A. A DataSource is the basic service for managing a set of JDBC drivers B. A DataSource is the Java representation of a physical data source C. A DataSource
More informationSQL in a Server Environment
SQL in a Server Environment Vaidė Narváez Computer Information Systems January 13th, 2011 The Three-Tier Architecture Application logic components Copyright c 2009 Pearson Education, Inc. Publishing as
More informationInstructor: Jinze Liu. Fall 2008
Instructor: Jinze Liu Fall 2008 Database Project Database Architecture Database programming 2 Goal Design and implement a real application? Jinze Liu @ University of Kentucky 9/16/2008 3 Goal Design and
More informationThis lecture. Databases - JDBC I. Application Programs. Database Access End Users
This lecture Databases - I The lecture starts discussion of how a Java-based application program connects to a database using. (GF Royle 2006-8, N Spadaccini 2008) Databases - I 1 / 24 (GF Royle 2006-8,
More informationJava and the Java DataBase Connectivity (JDBC) API. Todd Kaufman April 25, 2002
Java and the Java DataBase Connectivity (JDBC) API Todd Kaufman April 25, 2002 Agenda BIO Java JDBC References Q&A Speaker 4 years Java experience 4 years JDBC experience 3 years J2EE experience BS from
More informationPersistency Patterns. Repository and DAO
Persistency Patterns Repository and DAO 1 Repository pattern Basically, the Repository pattern just means putting a façade over your persistence system so that you can shield the rest of your application
More informationJDBC [Java DataBase Connectivity]
JDBC [Java DataBase Connectivity] Introduction Almost all the web applications need to work with the data stored in the databases. JDBC is Java specification that allows the Java programs to access the
More informationJDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server.
JDBC Drivers Type 1 What is JDBC Driver? JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. For example, using JDBC drivers enable you to open database
More informationJDBC MOCK TEST JDBC MOCK TEST IV
http://www.tutorialspoint.com JDBC MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to JDBC Framework. You can download these sample mock tests at your
More informationWhy use a database? You can query the data (run searches) You can integrate with other business systems that use the same database You can store huge
175 Why use a database? You can query the data (run searches) You can integrate with other business systems that use the same database You can store huge numbers of records without the risk of corruption
More informationLecture 9&10 JDBC. Mechanism. Some Warnings. Notes. Style. Introductory Databases SSC Introduction to DataBases 1.
Lecture 9&10 JDBC Java and SQL Basics Data Manipulation How to do it patterns etc. Transactions Summary JDBC provides A mechanism for to database systems An API for: Managing this Sending s to the DB Receiving
More informationIntroduction to Databases
JAVA JDBC Introduction to Databases Assuming you drove the same number of miles per month, gas is getting pricey - maybe it is time to get a Prius. You are eating out more month to month (or the price
More informationWeb Applications and Database Connectivity using JDBC (Part II)
Web Applications and Database Connectivity using JDBC (Part II) Advanced Topics in Java Khalid Azim Mughal khalid@ii.uib.no http://www.ii.uib.no/~khalid/atij/ Version date: 2007-02-08 ATIJ Web Applications
More informationJDBC. Sun Microsystems has included JDBC API as a part of J2SDK to develop Java applications that can communicate with databases.
JDBC The JDBC TM API is the application programming interface that provides universal data access for the Java TM platform. In other words, the JDBC API is used to work with a relational database or other
More informationJDBC - INTERVIEW QUESTIONS
JDBC - INTERVIEW QUESTIONS http://www.tutorialspoint.com/jdbc/jdbc_interview_questions.htm Copyright tutorialspoint.com Dear readers, these JDBC Interview Questions have been designed specially to get
More informationLecture 2. Introduction to JDBC
Lecture 2 Introduction to JDBC Introducing JDBC According to Sun, JDBC is not an acronym, but is commonly misinterpreted to mean Java DataBase Connectivity JDBC: is an API that provides universal data
More informationDatabases and JDBC. by Vlad Costel Ungureanu for Learn Stuff
Databases and JDBC by Vlad Costel Ungureanu for Learn Stuff Working with Databases Create database using SQL scripts Connect to the database server using a driver Communicate with the database Execute
More informationJava Database Connectivity (JDBC) 25.1 What is JDBC?
PART 25 Java Database Connectivity (JDBC) 25.1 What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming
More informationUNIT III - JDBC Two Marks
UNIT III - JDBC Two Marks 1.What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for databaseindependent connectivity between the Java programming language and a wide
More informationUnit 3 - Java Data Base Connectivity
Two-Tier Database Design The two-tier is based on Client-Server architecture. The direct communication takes place between client and server. There is no mediator between client and server. Because of
More informationUnit 2 JDBC Programming
Q1. What is JDBC? Explain the types of JDBC drivers? Ans. What is JDBC? JDBC is an API, which is used in java programming for interacting with database. JDBC (Java DataBase Connection) is the standard
More informationAccessing databases in Java using JDBC
Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.
More informationOverview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.)
Overview Database Application Development Chapter 6 Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures Database Management Systems 3ed
More informationDatabase Application Development
Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures
More informationDatabase Application Development
Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures
More informationEnterprise Java Unit 1- Chapter 6 Prof. Sujata Rizal
Introduction JDBC is a Java standard that provides the interface for connecting from Java to relational databases. The JDBC standard is defined by Sun Microsystems and implemented through the standard
More informationThe Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets
Course Name: Advanced Java Lecture 13 Topics to be covered The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets Introducing
More informationWorking with Databases and Java
Working with Databases and Java Pedro Contreras Department of Computer Science Royal Holloway, University of London January 30, 2008 Outline Introduction to relational databases Introduction to Structured
More informationSQL DML and DB Applications, JDBC
SQL DML and DB Applications, JDBC Week 4.2 Week 4 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints and SQL DDL
More informationJDBC, Transactions. Niklas Fors JDBC 1 / 38
JDBC, Transactions SQL in Programs Embedded SQL and Dynamic SQL JDBC Drivers, Connections, Statements, Prepared Statements Updates, Queries, Result Sets Transactions Niklas Fors (niklas.fors@cs.lth.se)
More informationDatabase Application Development
CS 461: Database Systems Database Application Development supplementary material: Database Management Systems Sec. 6.2, 6.3 DBUtils.java, Student.java, Registrar.java, RegistrarServlet.java, PgRegistrar.sql
More informationJava Database Connectivity
Java Database Connectivity INTRODUCTION Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Introduction
More informationDiscuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity
Objectives Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Setting Up JDBC Before you can begin to utilize JDBC, you must
More informationCSCI/CMPE Object-Oriented Programming in Java JDBC. Dongchul Kim. Department of Computer Science University of Texas Rio Grande Valley
CSCI/CMPE 3326 Object-Oriented Programming in Java JDBC Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Introduction to Database Management Systems Storing data in traditional
More informationPart I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017
Introduction to SQL Programming Techniques CSC 375, Fall 2017 The Six Phases of a Project: Enthusiasm Disillusionment Panic Search for the Guilty Punishment of the Innocent Praise for non-participants
More informationDatabase Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford
Database Programming Week 9 *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford SQL in Real Programs We have seen only how SQL is used at the generic query interface
More informationPieter van den Hombergh. March 25, 2018
ergh Fontys Hogeschool voor Techniek en Logistiek March 25, 2018 ergh/fhtenl March 25, 2018 1/25 JDBC JDBC is a Java database connectivity technology (Java Standard Edition platform) from Oracle Corporation.
More informationTop 50 JDBC Interview Questions and Answers
Top 50 JDBC Interview Questions and Answers 1) What is the JDBC? JDBC stands for Java Database Connectivity. JDBC is a Java API that communicates with the database and execute SQLquery. 2) What is a JDBC
More informationWhat is Transaction? Why Transaction Management Required? JDBC Transaction Management in Java with Example. JDBC Transaction Management Example
JDBC Transaction Management in Java with Example Here you will learn to implement JDBC transaction management in java. By default database is in auto commit mode. That means for any insert, update or delete
More informationSNS COLLEGE OF ENGINEERING, Coimbatore
SNS COLLEGE OF ENGINEERING, Coimbatore 641 107 Accredited by NAAC UGC with A Grade Approved by AICTE and Affiliated to Anna University, Chennai IT6503 WEB PROGRAMMING UNIT 03 JDBC JDBC Overview JDBC implementation
More informationCOP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA
COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA OUTLINE Postgresql installation Introduction of JDBC Stored Procedure POSTGRES INSTALLATION (1) Extract the source file Start the configuration
More informationObject Persistence Design Guidelines
Object Persistence Design Guidelines Motivation Design guideline supports architects and developers in design and development issues of binding object-oriented applications to data sources The major task
More informationMarcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science
Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science mluckner@mini.pw.edu.pl http://www.mini.pw.edu.pl/~lucknerm } JDBC ("Java Database Connectivity ) is a set
More informationDatabase Application Programs PL/SQL, Java and the Web
Database Application Programs PL/SQL, Java and the Web As well as setting up the database and running queries, it is vital to be able to build programs which manage the database although they will only
More informationDATABASE DESIGN I - 1DL300
DATABASE DESIGN I - 1DL300 Fall 2010 An introductory course on database systems http://www.it.uu.se/edu/course/homepage/dbastekn/ht10/ Manivasakan Sabesan Uppsala Database Laboratory Department of Information
More informationDB Programming. Database Systems
DB Programming Database Systems 1 Agenda MySQL data types Altering the Schema More Advanced MySQL JDBC DB Coding Tips 2 MySQL Data Types There are 3 main groups of types: Numeric Date String http://dev.mysql.com/doc/refman/5.6/en/data-types.html
More informationEnterprise JavaBeans. Layer:08. Persistence
Enterprise JavaBeans Layer:08 Persistence Agenda Discuss "finder" methods. Describe DataSource resources. Describe bean-managed persistence. Describe container-managed persistence. Last Revised: 11/1/2001
More informationCalling SQL from a host language (Java and Python) Kathleen Durant CS 3200
Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200 1 SQL code in other programming languages SQL commands can be called from within a host language (e.g., C++ or Java) program.
More information3) execute() Usage: when you cannot determine whether SQL is an update or query return true if row is returned, use getresultset() to get the
Agenda Lecture (07) Database connectivity (II) Connecting DB Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems 2 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems The
More informationDatabase connectivity (II)
Lecture (07) Database connectivity (II) Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems Agenda Connecting DB 2 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems The
More informationThe Web Application Developer s. Red Hat Database. View. October 30, Webcast. Patrick Macdonald, Fernando Nasser. Red Hat Database Engineering
Red Hat Database The Web Application Developer s View Webcast October 30, 2001 Patrick Macdonald, Fernando Nasser Liam Stewart, Neil Padgett Red Hat Database Engineering Agenda Red Hat Database Web Interaction
More informationJDBC. Oracle ODBC SP API SP API. SQL server C function calls. SQL server ODBC SP API. Oracle DSN Oracle ODBC Oracle
How to Interact with DataBase? THETOPPERSWAY.COM Generally every DB vendor provides a User Interface through which we can easily execute SQL query s and get the result (For example Oracle Query Manager
More informationUsing IBM-Informix datatypes with IDS 10 and web application server Keshava Murthy, IBM Informix Development
IBM GLOBAL SERVICES Using IBM-Informix datatypes with IDS 10 and web application server Keshava Murthy, IBM Informix Development Sept. 12-16, 2005 Orlando, FL 1 Agenda JDBC Datatypes IDS 10 Datatypes Java
More informationDB Programming. Database Systems, Presented by Rubi Boim
DB Programming Database Systems, 2008-2009 Presented by Rubi Boim 1 Agenda Project Details Basic Oracle Usage Little More Complex Oracle stuff.. JDBC Coding Tips 2 Database project TV/Movies DB Examples:
More informationDatabase in Applica.on Development. Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata
Database in Applica.on Deelopment Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata SQL from Programs SQL commands can be called from within a host language program C, C++, Jaa, Two
More informationAcknowledgments About the Authors
Acknowledgments p. xi About the Authors p. xiii Introduction p. xv An Overview of MySQL p. 1 Why Use an RDBMS? p. 2 Multiuser Access p. 2 Storage Transparency p. 2 Transactions p. 3 Searching, Modifying,
More informationOutline. Lecture 10: Database Connectivity -JDBC. Java Persistence. Persistence via Database
Outline Lecture 10: Database Connectivity -JDBC Persistence via Database JDBC (Java Database Connectivity) JDBC API Wendy Liu CSC309F Fall 2007 1 2 Java Persistence Persistence via Database JDBC (Java
More informationSQL and Java. Database Systems Lecture 20 Natasha Alechina
Database Systems Lecture 20 Natasha Alechina In this Lecture SQL in Java SQL from within other Languages SQL, Java, and JDBC For More Information Sun Java tutorial: http://java.sun.com/docs/books/tutorial/jdbc
More informationPERSİSTENCE OBJECT RELATİON MAPPİNG
PERSİSTENCE Most of the applications require storing and retrieving objects in a persistent storage mechanism. This chapter introduces how to store and retrieve information in a persistent storage with
More information13 Creation and Manipulation of Tables and Databases
150.420 Informationslogistik SQL Handout No. 9 SS 2013 13 Creation and Manipulation of Tables and Databases 13.1 Creation and Deletion Databases can be created and deleted using respectively. CREATE DATABASE
More informationCSE 308. Database Issues. Goals. Separate the application code from the database
CSE 308 Database Issues The following databases are created with password as changeit anticyber cyber cedar dogwood elm clan Goals Separate the application code from the database Encourages you to think
More informationINTRODUCTION TO JDBC - Revised Spring
INTRODUCTION TO JDBC - Revised Spring 2006 - 1 What is JDBC? Java Database Connectivity (JDBC) is an Application Programmers Interface (API) that defines how a Java program can connect and exchange data
More informationJDBC Programming: Intro
JDBC Programming: Intro Most interaction with DB is not via interactive interface Most people interact via 1. Application programs directly 2. Apps over the internet There are 3 general approaches to developing
More informationJDBC Installation Transactions Metadata
Course Name: Advanced Java Lecture 14 Topics to be covered JDBC Installation Transactions Metadata Steps in JDBC Connectivity:Connectivity:Here are the JDBC Steps to be followed while writing JDBC
More informationTuning Cloudscape Cloudscape Version 3.0 December 15, 1999
Tuning Cloudscape Cloudscape Version 3.0 December 15, 1999 Copyright 1997-1999 Cloudscape, Inc., 180 Grand Ave., Suite 300, Oakland, CA 94612. www.cloudscape.com. All rights reserved. Java is a registered
More informationBUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree
BUSINESS INTELLIGENCE LABORATORY Data Access: Relational Data Bases Business Informatics Degree RDBMS data access 2 Protocols and API ODBC, OLE DB, ADO, ADO.NET, JDBC JDBC Programming Java classes java.sql
More informationTiers (or layers) Separation of concerns
Tiers (or layers) Separation of concerns Hiding the type of storage from the client class Let s say we have a program that needs to fetch objects from a storage. Should the program have to be concerned
More informationFor this week, I recommend studying Chapter 2 of "Beginning Java EE 7".
For this week, I recommend studying Chapter 2 of "Beginning Java EE 7". http://find.lib.uts.edu.au/?r=opac_b2874770 261 We have been using a few container services and annotations but they have not been
More informationCOMP102: Introduction to Databases, 23
COMP102: Introduction to Databases, 23 Dr Muhammad Sulaiman Khan Department of Computer Science University of Liverpool U.K. 04 April, 2011 Programming with SQL Specific topics for today: Client/Server
More informationAnnouncements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week
Announcements 2 SQL: Part IV CPS 216 Advanced Database Systems Reading assignments for this week A Critique of ANSI SQL Isolation Levels, by Berenson et al. in SIGMOD 1995 Weaving Relations for Cache Performance,
More informationDatabase Applications. SQL/PSM Embedded SQL JDBC
Database Applications SQL/PSM Embedded SQL JDBC 1 Course Objectives Design Construction Applications Usage 2 Course Objectives Interfacing When the course is through, you should Know how to connect to
More informationsqoop Automatic database import Aaron Kimball Cloudera Inc. June 18, 2009
sqoop Automatic database import Aaron Kimball Cloudera Inc. June 18, 2009 The problem Structured data already captured in databases should be used with unstructured data in Hadoop Tedious glue code necessary
More informationDB I. 1 Dr. Ahmed ElShafee, Java course
Lecture (15) DB I Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, Java course Agenda 2 Dr. Ahmed ElShafee, Java course Introduction Java uses something called JDBC (Java Database Connectivity) to connect to databases.
More informationContent Services for JDBC Driver User Guide
Content Services for JDBC Driver User Guide Version 5.3 SP1 August 2005 Copyright 1994-2005 EMC Corporation. All rights reserved Table of Contents Preface... 7 Chapter 1 Introducing Content Services for
More informationDatabase Application Development
CS 500: Fundamentals of Databases Database Application Development supplementary material: Database Management Systems Sec. 6.2, 6.3 DBUtils.java, Student.java, Registrar.java, RegistrarServlet.java, PgRegistrar.sql
More informationAgenda. Naming & Directory Services. Extreme Java G Naming and directory services JNDI naming directory service provider interface Q & A
Extreme Java G22.3033-007 Session 8 - Sub-Topic 1 Java Naming and Directory Interface (JNDI) Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical
More informationVisit for more.
Chapter 6: Database Connectivity Informatics Practices Class XII (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra, PGT (Comp.Sc.)
More informationWentworth Institute of Technology COMP570 Database Applications Fall 2014 Derbinsky. SQL Programming. Lecture 8. SQL Programming
Lecture 8 1 Outline Context General Approaches Typical Programming Sequence Examples 2 Database Design and Implementation Process Normalization 3 SQL via API Embedded SQL SQLJ General Approaches DB Programming
More informationChapter 3 DB-Gateways
Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 3 DB-Gateways Outline Coupling DBMS and programming languages
More informationCHAPTER 2 JDBC FUNDAMENTALS
CHAPTER 2 JDBC FUNDAMENTALS OBJECTIVES After completing JDBC Fundamentals, you will be able to: Know the main classes in the JDBC API, including packages java.sql and javax.sql Know the difference between
More information