Self-test Database application programming with JDBC



Similar documents
SQL and Java. Database Systems Lecture 19 Natasha Alechina

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

Database Access Through Java Technologies

CS 377 Database Systems SQL Programming. Li Xiong Department of Mathematics and Computer Science Emory University

Why Is This Important? Database Application Development. SQL in Application Code. Overview. SQL in Application Code (Contd.

Making Oracle and JDBC Work For You

Database Access from a Programming Language: Database Access from a Programming Language

Database Access from a Programming Language:

Database Migration from MySQL to RDM Server

Building Web Applications, Servlets, JSP and JDBC

Oracle8/ SQLJ Programming

CS/CE 2336 Computer Science II

How To Use The Database In Jdbc.Com On A Microsoft Gdbdns.Com (Amd64) On A Pcode (Amd32) On An Ubuntu (Amd66) On Microsoft

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

COSC344 Database Theory and Applications. Java and SQL. Lecture 12

JDBC (Java / SQL Programming) CS 377: Database Systems

DEVELOPING MULTITHREADED DATABASE APPLICATION USING JAVA TOOLS AND ORACLE DATABASE MANAGEMENT SYSTEM IN INTRANET ENVIRONMENT

PL/SQL Programming Workbook

Performance Tuning for the JDBC TM API

CS346: Database Programming.

Database Programming. Week *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

Oracle to MySQL Migration

DATABASE SYSTEM CONCEPTS AND ARCHITECTURE CHAPTER 2

ODBC Chapter,First Edition

Java and Databases. COMP514 Distributed Information Systems. Java Database Connectivity. Standards and utilities. Java and Databases

Oracle Database: Program with PL/SQL

LSINF1124 Projet de programmation

Apache OFBiz Advanced Framework Training Video Transcription

Java DataBase Connectivity (JDBC)

TRANSACÇÕES. PARTE I (Extraído de SQL Server Books Online )

Chapter 2 Database System Concepts and Architecture

Course Objectives. Database Applications. External applications. Course Objectives Interfacing. Mixing two worlds. Two approaches

The first time through running an Ad Hoc query or Stored Procedure, SQL Server will go through each of the following steps.

The JAVA Way: JDBC and SQLJ

Introduction Web Portal Main Page Group Management Create group Modify Group Member List... 5

1 SQL Data Types and Schemas

CA IDMS Server r17. Product Overview. Business Value. Delivery Approach

Oracle Database: Program with PL/SQL

What is ODBC? Database Connectivity ODBC, JDBC and SQLJ. ODBC Architecture. More on ODBC. JDBC vs ODBC. What is JDBC?

To create a universal SQL client for accessing local or remote database ( 35.2). To execute SQL statements in a batch mode ( 35.3).

Duration Vendor Audience 5 Days Oracle Developers, Technical Consultants, Database Administrators and System Analysts

Oracle Database: Program with PL/SQL

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

Jaybird 2.1 JDBC driver. Java Programmer's Manual

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

Oracle Database: Program with PL/SQL

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Statement Level Interface. Call Level Interface. Static SQL. Status. Connections. Transactions. To connect to an SQL database, use a connect statement

ASP.NET Programming with C# and SQL Server

Overview. Database Application Development. SQL in Application Code (Contd.) SQL in Application Code. Embedded SQL. Embedded SQL: Variables

Choosing a Data Model for Your Database

Chapter 6 The database Language SQL as a tutorial

Oracle Database: Program with PL/SQL

Database Programming with PL/SQL: Learning Objectives

CS2506 Operating Systems II Lab 8, 8 th Tue/03 /2011 Java API

Using SQL Developer. Copyright 2008, Oracle. All rights reserved.

Java EE Web Development Course Program

1 File Processing Systems

Database Application Development. Overview. SQL in Application Code. Chapter 6

Oracle Database: SQL and PL/SQL Fundamentals

Module 4: File Reading. Module 5: Database connection

1.264 Lecture 15. SQL transactions, security, indexes

14 Triggers / Embedded SQL

Evaluation. Copy. Evaluation Copy. Chapter 7: Using JDBC with Spring. 1) A Simpler Approach ) The JdbcTemplate. Class...

Abstract. Introduction. Web Technology and Thin Clients. What s New in Java Version 1.1

Module 1: Getting Started with Databases and Transact-SQL in SQL Server 2008

Chapter 13. Introduction to SQL Programming Techniques. Database Programming: Techniques and Issues. SQL Programming. Database applications

Accesssing External Databases From ILE RPG (with help from Java)

Supplement IV.D: Tutorial for MS Access. For Introduction to Java Programming By Y. Daniel Liang

JDBC. It is connected by the Native Module of dependent form of h/w like.dll or.so. ex) OCI driver for local connection to Oracle

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

Java and RDBMS. Married with issues. Database constraints

More SQL: Assertions, Views, and Programming Techniques

Oracle Database 11g: Program with PL/SQL

Oracle Database: SQL and PL/SQL Fundamentals NEW

Using DataDirect Connect for JDBC with Oracle Real Application Clusters (RAC)

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

IBM DB2 XML support. How to Configure the IBM DB2 Support in oxygen

Equipment Room Database and Web-Based Inventory Management

FileMaker 11. ODBC and JDBC Guide

Mimer SQL. Programmer s Manual. Version 8.2 Copyright 2000 Mimer Information Technology AB

Oracle Database: SQL and PL/SQL Fundamentals

A Generic Database Web Service

WS-JDBC. (Web Service - Java DataBase Connectivity) Remote database access made simple: 1.

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

ODBC Driver Guide. July Version 9.1

Oracle WebLogic Server

HP NonStop JDBC Type 4 Driver Performance Tuning Guide for Version 1.0

Spring Data JDBC Extensions Reference Documentation

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

T-SQL STANDARD ELEMENTS

The Data Access Handbook

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours

TABLE OF CONTENTS...2 INTRODUCTION...3 APPLETS AND APPLICATIONS...3 JAVABEANS...4 EXCEPTION HANDLING...5 JAVA DATABASE CONNECTIVITY (JDBC)...

Oracle Database 10g: Program with PL/SQL

Transcription:

Self-test Database application programming with JDBC Document: e1216test.fm 18/04/2012 ABIS Training & Consulting P.O. Box 220 B-3000 Leuven Belgium TRAINING & CONSULTING

INTRODUCTION TO THE SELF-TEST DATABASE APPLICATION PROGRAMMING WITH JDBC This test is based on subjects handled in the ABIS course Data base application programming with JDBC. This test consists of multiple-choice questions. With some questions, multiple correct answers are possible. Write down your answer(s) and compare with the given solutions. This test contains 20 questions. Note: if multiple answers are possible, this is explicitly indicated. A question is answered correctly if and only if all correct answers are given. There are no catch-questions (not intended), but it is advised to read all questions and answers attentively. Count about 15 minutes to complete the test. The correct answers and the guidelines for the evaluation are at the back of this document. 18/04/2012 Self-test Database application programming with JDBC 2

QUESTIONS SELF-TEST DATABASE APPLICATION PROGRAMMING WITH JDBC 1. Which statements about JDBC are true? (2 answers) [_] [a] [_] [b] [_] [c] [_] [d] JDBC is an API to connect to relational-, object- and XML data sources JDBC stands for Java DataBase Connectivity JDBC is an API to access relational databases, spreadsheets and flat files JDBC is an API to bridge the object-relational mismatch between OO programs and relational databases 2. Which packages contain the JDBC classes? O (a) java.jdbc and javax.jdbc O (b) java.jdbc and java.jdbc.sql O (c) java.sql and javax.sql O (d) java.rdb and javax.rdb 3. Which type of driver converts JDBC calls into the network protocol used by the database management system directly? O (a) Type 1 driver O (b) Type 2 driver O (c) Type 3 driver O (d) Type 4 driver 4. Which type of Statement can execute parameterized queries? O (a) PreparedStatement O (b) ParameterizedStatement O (c) ParameterizedStatement and CallableStatement O (d) All kinds of Statements (i.e. which implement a sub interface of Statement) 18/04/2012 Self-test Database application programming with JDBC 3

5. How can you retrieve information from a ResultSet? O (a) By invoking the method get(..., String type) on the ResultSet, where type is the database type O (b) By invoking the method get(..., Type type) on the ResultSet, where Type is an object which represents a database type O (c) By invoking the method getvalue(...), and cast the result to the desired Java type. O (d) By invoking the special getter methods on the ResultSet: getstring(...), getboolean (...), getclob(...),... 6. How can you execute DML statements (i.e. insert, delete, update) in the database? O (a) By making use of the InsertStatement, DeleteStatement or UpdateStatement classes O (b) By invoking the execute(...) or executeupdate(...) method of a normal Statement object or a sub-interface object thereof O (c) By invoking the executeinsert(...), executedelete(...) or executeupdate(...) methods of the DataModificationStatement object O (d) By making use of the execute(...) statement of the DataModificationStatement object 7. How do you know in your Java program that a SQL warning is generated as a result of executing a SQL statement in the database? O (a) You must catch the checked SQLException which is thrown by the method which executes the statement O (b) You must catch the unchecked SQLWarningException which is thrown by the method which executes the statement O (c) You must invoke the getwarnings() method on the Statement object (or a sub interface thereof) O (d) You must query the ResultSet object about possible warnings generated by the database 8. What is, in terms of JDBC, a DataSource? O (a) A DataSource is the basic service for managing a set of JDBC drivers O (b) A DataSource is the Java representation of a physical data source O (c) A DataSource is a registry point for JNDI-services O (d) A DataSource is a factory of connections to a physical data source 18/04/2012 Self-test Database application programming with JDBC 4

9. What is the meaning of ResultSet.TYPE_SCROLL_INSENSITIVE O (a) This means that the ResultSet is insensitive to scrolling O (b) This means that the Resultset is sensitive to scrolling, but insensitive to updates, i.e. not updateable O (c) This means that the ResultSet is sensitive to scrolling, but insensitive to changes made by others O (d) The meaning depends on the type of data source, and the type and version of the driver you use with this data source 10. Are ResultSets updateable? O (a) Yes, but only if you call the method opencursor() on the ResultSet, and if the driver and database support this option O (b) Yes, but only if you indicate a concurrency strategy when executing the statement, and if the driver and database support this option O (c) Yes, but only if the ResultSet is an object of class UpdateableResultSet, and if the driver and database support this option O (d) No, ResultSets are never updateable. You must explicitly execute DML statements (i.e. insert, delete and update) to change the data in the underlying database 11. What statements are correct about JDBC transactions (2 correct answers)? [_] [a] [_] [b] [_] [c] [_] [d] A transaction is a set of successfully executed statements in the database A transaction is finished when commit() or rollback() is called on the Connection object, A transaction is finished when commit() or rollback() is called on the Transaction object A transaction is finished when close() is called on the Connection object. 12. How can you start a database transaction in the database? O (a) By asking a Transaction object to your Connection, and calling the method begin() on it O (b) By asking a Transaction object to your Connection, and setting the autocommit property of the Transaction to false O (c) By calling the method begintransaction() on the Connection object O (d) By setting the autocommit property of the Connection to false, and execute a statement in the database 18/04/2012 Self-test Database application programming with JDBC 5

13. What is the meaning of the transaction isolation level TRANSACTION_REPEATABLE_READ O (a) Dirty reads, non-repeatable reads and phantom reads can occur O (b) Dirty reads are prevented; non-repeatable reads and phantom reads can occur O (c) Dirty reads and non-repeatable reads are prevented; phantom reads can occur O (d) Dirty reads, non-repeatable reads and phantom reads are prevented 14. How do you use a savepoint? O (a) A savepoint is realised by calling setautocommit(true) on the connection O (b) A savepoint is activated by the method setsavepoint( mysavepoint ) on the transaction O (c) A savepoint is used to mark intermediate points inside a transaction, in order to get a more fine-grained control. Transactions can be rolled back to a previous savepoint without affecting preceding work. O (d) A savepoint triggers an automatic synchronisation with the database. 15. What statements are correct about positioned updates (i.e. cursor updates) in ResultSets? (2 correct answers) [_] [a] [_] [b] [_] [c] [_] [d] Using the cursor technique is currently the only possible way to change the data in the current row of a ResultSet Insert statements are only supported when using scrollable cursors. Only scrollable updateable ResultSets can use this approach to change the data in the current row of a ResultSet The name of the cursor is specified by the setcursorname(string name) method the Statement object. 16. How can you execute a stored procedure in the database? O (a) Call method execute() on a CallableStatement object O (b) Call method executeprocedure() on a Statement object O (c) Call method execute() on a StoredProcedure object O (d) Call method run() on a ProcedureCommand object 17. What happens if you call the method close() on a ResultSet object? O (a) the method close() does not exist for a ResultSet. Only Connections can be closed. O (b) the database and JDBC resources are released O (c) you will get a SQLException, because only Statement objects can close ResultSets O (d) the ResultSet, together with the Statement which created it and the Connection from which the Statement was retrieved, will be closed and release all database and JDBC resources 18/04/2012 Self-test Database application programming with JDBC 6

18. What happens if you call deleterow() on a ResultSet object? O (a) The row you are positioned on is deleted from the ResultSet, but not from the database. O (b) The row you are positioned on is deleted from the ResultSet and from the database O (c) The result depends on whether the property synchronizewithdatasource is set to true or false O (d) You will get a compile error: the method does not exist because you can not delete rows from a ResultSet 19. What statements are correct about batched insert and updates? (2 answers) [_] [a] [_] [b] [_] [c] [_] [d] To create a batch of insert and update statements, you create an object of type Batch, and call the method addstatement(string statement) for each statement you want to execute in the batch Batch insert and updates are only possible when making use of parameterized queries. To do a batched update/insert, you call addbatch(string statement) on a Statement object for each statement you want to execute in the batch To execute a batched update/insert, you call the executebatch() method on a Statement object 20. What is correct about DDL statements (create, grant,...)? O (a) DDL statements are treated as normal SQL statements, and are executed by calling the execute() method on a Statement (or a sub interface thereof) object O (b) To execute DDL statements, you have to install additional support files O (c) DDL statements can not be executed by making use of JDBC, you should use the native database tools for this. O (d) Support for DDL statements will be a feature of a future release of JDBC 18/04/2012 Self-test Database application programming with JDBC 7

EVALUATION. Here are the correct answers to all questions: 1. b c 2. c 3. d 4. a 5. d 6. b 7. c 8. d 9. c 10. b 11. b d 12. d 13. c 14. c 15. b d 16. a 17. b 18. b 19. c d 20. a Give 1 point per correct answer. For questions with multiple correct answers, all correct answers must be given before 1 point is earned. No half points are given. If your score is more than 80%, you do not have to follow the course Data base application programming with JDBC. When you have a score between 50% and 80%, following the course Data base application programming with JDBC can improve your knowledge. When your score is less than 50%, we strongly suggest you follow this course Data base application programming with JDBC. 18/04/2012 Self-test Database application programming with JDBC 8