- Lesson: JDBC Basics
- Java database programming with jdbc
- 404 — FILE NOT FOUND
- Host Information (Europe2 CDN)
- Lesson: JDBC Introduction
- JDBC Product Components
- Database Programming with JDBC & Java, Second Edition
- Book description
- Publisher resources
- Table of contents
- Product information
- You might also like
- Check it out now on O’Reilly
Lesson: JDBC Basics
In this lesson you will learn the basics of the JDBC API.
- Getting Started sets up a basic database development environment and shows you how to compile and run the JDBC tutorial samples.
- Processing SQL Statements with JDBC outlines the steps required to process any SQL statement. The pages that follow describe these steps in more detail:
- Establishing a Connection connects you to your database.
- Connecting with DataSource Objects shows you how to connect to your database with DataSource objects, the preferred way of getting a connection to a data source.
- Handling SQLExceptions shows you how to handle exceptions caused by database errors.
- Setting Up Tables describes all the database tables used in the JDBC tutorial samples and how to create and populate tables with JDBC API and SQL scripts.
- Retrieving and Modifying Values from Result Sets develop the process of configuring your database, sending queries, and retrieving data from your database.
- Using Prepared Statements describes a more flexible way to create database queries.
- Using Transactions shows you how to control when a database query is actually executed.
- Using JdbcRowSet Objects
- Using CachedRowSetObjets
- Using JoinRowSet Objects
- Using FilteredRowSet Objects
- Using WebRowSet Objects
- Using Large Objects
- Using SQLXML Objects
- Using Array Objects
- Using DISTINCT Data Type
- Using Structured Objects
- Using Customized Type Mappings
- Using Datalink Objects
- Using RowId Objects
Java database programming with jdbc
- alien & ufo
- anarchy & privacy control
- art
- automotive
- body & health
- computer culture
- computing
- conspiracy
- drugs
- education
- engineering
- finance & marketing
- gaming & diversion
- geography
- government information
- history
- laugh
- law
- literature
- lyrics & music related
- mathematics
- movie & TV scripts
- news & media
- politics
- food & recipes
- religion, occult, new age
- science & technology
- sex
- space
- sporting & recreation
- survival
- terrorism & pyrotechnics
- thought & writing
- underground
- UN & NATO
- wars & weapons
404 — FILE NOT FOUND
Sorry, it seems that the file you’re attempting to access no longer exists! The file may have been renamed or removed from the archive. Please use the navigation links on the left to browse the area of the archive you’d like to visit.
Host Information (Europe2 CDN)
You are connected to cdn.preterhuman.net which mirrors the Higher Intellect archive out of Italy. Available bandwidth is up to 100Mbit. This mirror was created on March 19/2013.
Current bandwidth utilization 1.68 Mbit/s
Lesson: JDBC Introduction
The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a relational database.
JDBC helps you to write Java applications that manage these three programming activities:
- Connect to a data source, like a database
- Send queries and update statements to the database
- Retrieve and process the results received from the database in answer to your query
The following simple code fragment gives a simple example of these three steps:
public void connectToAndQueryDatabase(String username, String password) < Connection con = DriverManager.getConnection( "jdbc:myDriver:myDatabase", username, password); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1"); while (rs.next()) < int x = rs.getInt("a"); String s = rs.getString("b"); float f = rs.getFloat("c"); >>
This short code fragment instantiates a DriverManager object to connect to a database driver and log into the database, instantiates a Statement object that carries your SQL language query to the database; instantiates a ResultSet object that retrieves the results of your query, and executes a simple while loop, which retrieves and displays those results. It’s that simple.
JDBC Product Components
JDBC includes four components:
- The JDBC API — The JDBC™ API provides programmatic access to relational data from the Java™ programming language. Using the JDBC API, applications can execute SQL statements, retrieve results, and propagate changes back to an underlying data source. The JDBC API can also interact with multiple data sources in a distributed, heterogeneous environment. The JDBC API is part of the Java platform, which includes the Java™ Standard Edition (Java™ SE ) and the Java™ Enterprise Edition (Java™ EE). The JDBC 4.0 API is divided into two packages: java.sql and javax.sql. Both packages are included in the Java SE and Java EE platforms.
- JDBC Driver Manager — The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager has traditionally been the backbone of the JDBC architecture. It is quite small and simple. The Standard Extension packages javax.naming and javax.sql let you use a DataSource object registered with a Java Naming and Directory Interface™ (JNDI) naming service to establish a connection with a data source. You can use either connecting mechanism, but using a DataSource object is recommended whenever possible.
- JDBC Test Suite — The JDBC driver test suite helps you to determine that JDBC drivers will run your program. These tests are not comprehensive or exhaustive, but they do exercise many of the important features in the JDBC API.
- JDBC-ODBC Bridge — The Java Software bridge provides JDBC access via ODBC drivers. Note that you need to load ODBC binary code onto each client machine that uses this driver. As a result, the ODBC driver is most appropriate on a corporate network where client installations are not a major problem, or for application server code written in Java in a three-tier architecture.
This Trail uses the first two of these four JDBC components to connect to a database and then build a java program that uses SQL commands to communicate with a test relational database. The last two components are used in specialized environments to test web applications, or to communicate with ODBC-aware DBMSs.
Database Programming with JDBC & Java, Second Edition
Read it now on the O’Reilly learning platform with a 10-day free trial.
O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.
Book description
Java and databases make a powerful combination. Getting the two sides to work together, however, takes some effort—largely because Java deals in objects while most databases do not.
This book describes the standard Java interfaces that make portable object-oriented access to relational databases possible and offers a robust model for writing applications that are easy to maintain. It introduces the JDBC and RMI packages and uses them to develop three-tier applications (applications divided into a user interface, an object-oriented logic component, and an information store).
The book begins with a quick overview of SQL for developers who may be asked to handle a database for the first time. It then explains how to issue database queries and updates through SQL and JDBC. It also covers the use of stored procedures and other measures to improve efficiency, where these are available.
But the book’s key contribution is a set of patterns that let developers isolate critical tasks like object creation, information storage and retrieval, and the committing or aborting of transactions.
The second edition includes more basics of JDBC and SQL, with more examples, and a deeper discussion about the architecture of a robust, maintainable database application. The second edition also explains the relationship between JDBC and Enterprise JavaBeans.
Publisher resources
Table of contents
- Database Programming with JDBC and Java, 2nd Edition
- Preface
- Audience
- Using This Book
- Software and Versions
- Conventions Used in This Book
- Comments and Questions
- About the Philosophers
- Acknowledgments
- Feedback for the Author
- 1. Java in the Enterprise
- The Enterprise
- A Business in Need of an Enterprise Solution
- Requirements for a True Enterprise System
- The Java APIs and Platform Independence
- Internationalization, Localization, and Accessibility
- Sharing Business Concepts Across the Business
- How Java Interacts with a Database
- SQL
- JDBC
- Transaction management
- Putting It All Together
- What Is a Relational Database?
- An Introduction to SQL
- CREATE
- INSERT
- UPDATE
- DELETE
- SELECT
- Joins and Subqueries
- Transaction Logic
- What Is JDBC?
- The Structure of JDBC
- Databases and Drivers
- Alternatives to JDBC
- The JDBC Classes for Creating a Connection
- Basic JDBC Database Access Classes
- SQL NULL Versus Java null
- Clean Up
- Modifying the Database
- Result Set Types
- Result Set Navigation
- Determining Where You Are
- Helping Your Driver with Scrollable Result Sets
- java.sql.Types
- java.sql.SQLException
- java.sql.SQLWarning and java.sql.DataTruncation
- java.sql.Date, java.sql.Time, and java.sql.Timestamp
- Getting Configuration Information
- Showing Random-Visitor Comments on an HTTP GET
- Saving New Comments
- Getting parameter values
- Generating a new comment ID
- Inserting a new comment
- Prepared SQL
- Prepared Statements
- Stored Procedures
- Updates
- Deletes
- Inserts
- Visibility of Changes
- Refreshing Data from the Database
- Blobs and Clobs
- Arrays
- Other SQL3 Types
- Java Types
- Type Mapping
- Result Set Meta-Data
- Database Meta-Data
- Driver Property Information
- A Generic Terminal Monitor
- Data Sources
- Naming and Directory Services
- Configuration
- Usage
- Rowset Events
- 6. Other Enterprise APIs
- Java Naming and Directory Interface
- Naming and Directory Services
- Object Binding
- Object Lookup
- The Structure of RMI
- Access to remote objects
- Remote interfaces
- Stubs and skeletons
- The special exception: java.rmi.RemoteException
- EJB Roles
- Kinds of Beans
- Architecture
- Strategic Versus Tactical
- Architectural Questions
- Common Architectures
- Two-tier client/server
- Two-tier limitations
- Fat clients
- Object reuse
- Isolated database connectivity
- Centralized business processing
- Business object presentation
- Client Patterns
- The model-view-controller pattern
- The listener pattern
- The distributed listener pattern
- The composite pattern
- The factory pattern
- The persistence delegate pattern
- The memento pattern
- The Business Objects
- Persistence
- The User Interface
- Kinds of Distributed Components
- Process-Oriented Components
- Persistent Components
- Component Security
- Authentication
- Validation
- Transaction Boundaries
- Tracking Changes
- Other Transaction Management Issues
- Façades
- Collections
- Database Transactions
- Mementos and Delegates
- JDBC Persistence
- Searches
- Swing at a Glance
- Model-View-Controller
- Threads in Swing
- A Two-Tier Model
- A Three-Tier Model
- 11. JDBC Reference
- Reference
- Array
- Blob
- CallableStatement
- Clob
- Connection
- DatabaseMetaData
- Date
- Driver
- DriverManager
- DriverPropertyInfo
- PreparedStatement
- Ref
- ResultSet
- ResultSetMetaData
- SQLData
- SQLInput
- SQLOutput
- Statement
- Struct
- Time
- Timestamp
- Types
- Reference
- ConnectionEvent
- ConnectionEventListener
- ConnectionPoolDataSource
- DataSource
- PooledConnection
- RowSet
- RowSetEvent
- RowSetInternal
- RowSetListener
- RowSetMetaData
- RowSetReader
- RowSetWriter
- XAConnection
- XADataSource
Product information
- Title: Database Programming with JDBC & Java, Second Edition
- Author(s): George Reese
- Release date: August 2000
- Publisher(s): O’Reilly Media, Inc.
- ISBN: 9781565926165
You might also like
Check it out now on O’Reilly
Dive in for free with a 10-day trial of the O’Reilly learning platform—then explore all the other resources our members count on to build skills and solve problems every day.
- Reference
- Java Naming and Directory Interface
- The Enterprise
- Preface