1 juni 30, 2005 Spring JDBC. 2 juni 30, 2005 Doel Database acties Flexibel Gecontroleerd Productief.

Slides:



Advertisements
Similar presentations
Java Database Conectivity Julio M. Faerman. Arquitetura Java Database Connectivity # 2 AplicaçãoJDBC API Driver Manager JDBC Driver SGBDR AplicaçãoJDBC.
Advertisements

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
5 Copyright © 2005, Oracle. All rights reserved. Accessing the Database with Servlets.
16 Copyright © 2005, Oracle. All rights reserved. Using JDBC to Access the Database.
Persistence Jim Briggs 1. 2 Database connectivity: JDBC Java Database Connectivity An API for connecting Java programs (applications, applets and servlets)
CE203 - Application Programming Autumn 2013CE203 Part 51 Part 5.
Java II--Copyright © Tom Hunter. Chapter 18 JDBC.
Exercises of the Tutorial on Advanced Web Programming Authors: Miroslava Mitrovic Dragan Milicev Nino.
Database By: Greg 4/10/2017 Java 9 - GUI.
My_Demo_Test : Air –Pollution measured at certain time points in a day t0t1t2t3t
Database programming in Java An introduction to Java Database Connectivity (JDBC)
15-Jun-15 JDBC. JDBC is a Sun trademark It is often taken to stand for Java Database Connectivity Java is very standardized, but there are many versions.
1 JDBC Java Database Connectivity. 2 c.pdf
Last Update: 5/15/061 Spring J2EE Framework Ram A. Rao May 15 th ‘05.
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 Java Database Connection (JDBC) There are many industrial-strength DBMS's commercially available in the market. Oracle, DB2, and Sybase are just a few.
UPortal Developers MIT August 2004 Persistence Strategy for uPortal 3 Mike DeSimone the r-smart group
Agenda What is Hibernate Spring Integration Questions Overview
CS178 Database Management “JDBC”. What is JDBC ? JDBC stands for “Java DataBase Connectivity” The standard interface for communication between a Java.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 8 Object Oriented Programming in Java Advanced Topics Java Database.
© Wang Bin 2004 JDBC ----Java Database Connectivity.
Java Database Connectivity ASE. Java Database Connectivity (JDBC) l JDBC – provides an interface to Relational Data Sources l JDBC library provides the.
Database Programming in Java Corresponds with Chapter 32, 33.
Introduction to the Spring Framework Rajesh. Spring Mission Statement J2EE should be easier to use OO design is more important than any implementation.
Using Java with PSQL and Oracle Thanks to Drs. Raj and Liu for sharing some of these slides TRUDY: ALSO NEED SAMPLE PROGRAM.
1 Oracle Consulting – Java Professional Community – 29 augustus 2005 Spring – Power to the POJO Introductie tot het Spring Framework Lucas Jellema Oracle.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 302 Database Systems Java Data Base Connectivity Lecturer Dr Pavle Mogin.
1 KC Web & Java – 29 november 2005 – Design Patterns – The Template Method AJAX! KC Web & Java 29 november 2005.
Spring Data Access By, Srinivas Reddy.S
JDBC Java and Databases, including Postgress. JDBC l Developed by Industry leaders l Three main goals: –JDBC should be an SQL-level API –JDBC should capitalize.
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
JDBC. JDBC stands for Java Data Base Connectivity. JDBC is different from ODBC in that – JDBC is written in Java (hence is platform independent, object.
JDBC  The JDBC (Java Database Connectivity) API helps a Java program to access a database in a standard way  JDBC is a specification that tells the.
Spring Database Access Ojitha Kumanayaka Copyright © Virtusa, 2007.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
Copyright  Oracle Corporation, All rights reserved. 6 Accessing a Database Using the JDBC API.
Copyright  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
Java Database Connectivity. Java and the database Database is used to store data. It is also known as persistent storage as the data is stored and can.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
Creating competitive advantage Copyright © 2003 Enterprise Java Beans Presenter: Wickramanayake HMKSK Version:0.1 Last Updated:
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.
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
16 Java Database Connectivity. 2 Understand the JDBC Understand the steps of the JDBC: 1.) Importing packages 2.) Opening a connection to a database 3.)
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Database Programming With Java & JDBC Reading: DD Ch. 18, pp al/jdbc/index.html, or anything covering JDBC.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring JDBC Simplifying.
Spring JDBC Dima Ionut Daniel. Contents What is Spring JDBC? Overview Spring JDBC Core SQL Exceptions Database Connection Batch Operations Handling BLOB/CLOB.
1 JDBC – Java Database Connectivity CS , Spring 2010.
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
CS422 Principles of Database Systems JDBC and Embedded SQL Chengyu Sun California State University, Los Angeles.
Современные технологии баз данных Лекция 7. Объектно-реляционное отображение (ORM) Технология отображения объектов какого- либо объектно-ориентированного.
ㅇ 데이터베이스 연동 지원 - 템플릿 클래스를 통한 데이터 접근 지원 - 의미있는 예외 클래스 제공 - 트랜잭션 처리 ㅇ Connection / PreparedStatement / ResultSet / try-catch 등 JDBC 중복 코드 제거 JDBC.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
CS3220 Web and Internet Programming Database Access with JDBC
JDBC – Java Database Connectivity
CS320 Web and Internet Programming Database Access with JDBC
Interacting with Database
Spring 프레임워크의 이해 5. Spring Abstract API.
JDBC Example.
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Presentation transcript:

1 juni 30, 2005 Spring JDBC

2 juni 30, 2005 Doel Database acties Flexibel Gecontroleerd Productief

3 juni 30, 2005 Database acties CRUD stored procedures Lob...

4 juni 30, 2005 Flexibel jdbc ORM framework connection pooling datasource testen  outside container  mock objecten Database onafhankelijk (?!)

5 juni 30, 2005 Gecontroleerd Exception handling Connection leaking

6 juni 30, 2005 Productief gericht op functie geen plumbing

7 juni 30, 2005 Architectuur Service DAO Domain Object Value Object Domain Object JNDI

8 juni 30, 2005 SIDE STEP - Architectuur issue Hoe implementeer je de emp – dept en emp – mgr relatie in de domein objecten? Hoe ga je met die relatie om in DAO’s?  ORM taak lazy loading vs... Department Employee

9 juni 30, 2005 Example import java.sql.*; import javax.sql.*; public class EmpDao { public List getAllEmployees() { Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; List emps = new ArrayList(); try { con = getConnection(); pstmt = con.prepareStatement ("select * from emp"); rs = pstmt.executeQuery(); while (rs.next()) { Employee e = new Employee(); e.setId (rs.getLong(1)); e.setName (rs.getString(2)); //... emps.add(e); } } catch (SQLException e) { // handle exception } finally { try { rs.close(); pstmt.close(); con.close(); } catch (SQLException e1) { // no action needed } return emps; } private Connection getConnection() throws SQLException { try { Context ic = new InitialContext(); DataSource ds = (DataSource) ic.lookup ("java:comp/env/jdbc/myDatabase"); return ds.getConnection(); } catch (NamingException e) { // handle exception return null; } private Connection getConnection() throws SQLException { try { DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); return DriverManager.getConnection "tiger"); } catch (SQLException sqle) { // handle exception return null; }

10 juni 30, 2005 How can Spring help? Make life easier: DAO Support  JDBC, Hibernate, Toplink, iBatis, JDO,... Dependency Injection Jdbc helper classes Exception Handling MockObjects

11 juni 30, 2005 Spring Architectuur Service DAO Domain Object Domain Object Domain Object DAO Interface ApplicationContext-jdbc XXDAO Support JdbcDaoSupport HibernateDaoSupport TopLinkDaoSupport...

12 juni 30, 2005 Example A public interface empDao { public List getAllEmployees (); } public class EmployeeJdbcDao extends JdbcDaoSupport implements EmpDao { public List getAllEmployees() { JdbcTemplate jt = getJdbcTemplate(); return jt.queryForList (“select * from emp”); } <bean id="dataSourceDBDirect" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">

13 juni 30, 2005 Exception Handling RuntimeException ipv checked SQLException  DataAccessException SQLException Translation  DataIntegrityViolationException  DataRetrievalFailureException  CannotGetJdbcConnectionException ...

14 juni 30, 2005 jdbc helper classes JdbcTemplate  query, queryForList, queryForInt, queryFor..  ArrayList (per row) of HashMaps (column name as key) RowMapper PreparedStatementCreator/Callback MappingSQLQuery...

15 juni 30, 2005 Testen en MockObjects public class TestEmployeeDao extends AbstractDependencyInjectionSpringContextTests { private EmployeeDao employeeDAO; public void setEmployeeDAO(EmployeeDao employeeDAO) { this.employeeDAO = employeeDAO; } protected String[] getConfigLocations() { return new String[] {"nl/amis/demo/dao/jdbc/applicationContext-jdbc.xml"}; } public void testFindEmployeeById () { Employee emp = employeeDAO.getEmployeeById(7839); assertEquals("KING", emp.getName()); assertEquals("PRESIDENT", emp.getJob()); //... }