100% found this document useful (1 vote)
9 views

MySQL and Java Developer s Guide 1st Edition Mark Matthews download

The document is a comprehensive guide on using MySQL with Java, authored by Mark Matthews, Jim Cole, and Joseph D. Gradecki. It covers topics such as JDBC, database design, transactions, and advanced functionalities, providing detailed instructions and examples. The book is published by Wiley Publishing, Inc. and includes various chapters focusing on installation, application development, and database administration.

Uploaded by

jadavahnen6m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
9 views

MySQL and Java Developer s Guide 1st Edition Mark Matthews download

The document is a comprehensive guide on using MySQL with Java, authored by Mark Matthews, Jim Cole, and Joseph D. Gradecki. It covers topics such as JDBC, database design, transactions, and advanced functionalities, providing detailed instructions and examples. The book is published by Wiley Publishing, Inc. and includes various chapters focusing on installation, application development, and database administration.

Uploaded by

jadavahnen6m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

MySQL and Java Developer s Guide 1st Edition

Mark Matthews download

https://ebookname.com/product/mysql-and-java-developer-s-
guide-1st-edition-mark-matthews/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Java 2 Web Developer Certification Study Guide 2nd


Edition Natalie Levi

https://ebookname.com/product/java-2-web-developer-certification-
study-guide-2nd-edition-natalie-levi/

Splunk Developer s Guide Second Edition Smith

https://ebookname.com/product/splunk-developer-s-guide-second-
edition-smith/

Programming Java 2 Micro Edition for Symbian OS A


developer s guide to MIDP 2 0 Martin De Jode

https://ebookname.com/product/programming-java-2-micro-edition-
for-symbian-os-a-developer-s-guide-to-midp-2-0-martin-de-jode/

Immune Dysfunction and Immunotherapy in Heart Disease


1st Edition Ronald Ross Watson

https://ebookname.com/product/immune-dysfunction-and-
immunotherapy-in-heart-disease-1st-edition-ronald-ross-watson/
Marx s Revenge The Resurgence of Capitalism and the
Death of Statist Socialism 1st Edition Meghnad Desai

https://ebookname.com/product/marx-s-revenge-the-resurgence-of-
capitalism-and-the-death-of-statist-socialism-1st-edition-
meghnad-desai/

Clean Coal 1st Edition Klaes G. Douwe

https://ebookname.com/product/clean-coal-1st-edition-klaes-g-
douwe/

The Healing Code 6 Minutes to Heal the Source of Your


Health Success or Relationship Issue 1st Edition Loyd

https://ebookname.com/product/the-healing-code-6-minutes-to-heal-
the-source-of-your-health-success-or-relationship-issue-1st-
edition-loyd/

A Little Book of Language 1st Edition David Crystal

https://ebookname.com/product/a-little-book-of-language-1st-
edition-david-crystal/

Urogenital Imaging Direct Diagnosis in Radiology DX


Direct Direct Diagnosis in Radiology 1st Edition Hamm

https://ebookname.com/product/urogenital-imaging-direct-
diagnosis-in-radiology-dx-direct-direct-diagnosis-in-
radiology-1st-edition-hamm/
First Mothers Bonnie Angelo

https://ebookname.com/product/first-mothers-bonnie-angelo/
MySQL and Java
Developer’s Guide

Mark Matthews
Jim Cole
Joseph D. Gradecki
Publisher: Robert Ipsen Copyeditor: Elizabeth Welch
Editor: Robert M. Elliott Proofreader: Nancy Sixsmith
Managing Editor: Vincent Kunkemueller Compositor: Gina Rexrode
Book Producer: Ryan Publishing Group, Inc.

Designations used by companies to distinguish their products are often claimed as trademarks. In all instances
where Wiley Publishing, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL
LETTERS. Readers, however, should contact the appropriate companies for more complete information regarding
trademarks and registration.

This book is printed on acid-free paper. ∞

Copyright © 2003 by Wiley Publishing, Inc. All rights reserved.

Published by Wiley Publishing, Inc., Indianapolis, Indiana

Published simultaneously in Canada.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under
Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the
Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center,
Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470. Requests to the Publisher for
permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd.,
Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-mail: [email protected].

Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing
this book, they make no representations or warranties with respect to the accuracy or completeness of the
contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particu-
lar purpose. No warranty may be created or extended by sales representatives or written sales materials. The
advice and strategies contained herein may not be suitable for your situation. You should consult with a profes-
sional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other
commercial damages, including but not limited to special, incidental, consequential, or other damages.

For general information on our other products and services please contact our Customer Care Department
within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Trademarks: Wiley, the Wiley Publishing logo and related trade dress are trademarks or registered trademarks
of Wiley Publishing, Inc., in the United States and other countries, and may not be used without written permis-
sion. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated
with any product or vendor mentioned in this book.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.

Library of Congress Cataloging-in-Publication Data:


Matthews, Mark.
MySQL and Java developer’s guide / Mark Matthews.
p. cm.
ISBN 0-471-26923-9 (PAPER/WEBSITE)
1. SQL (Computer program language) 2. Java (Computer program
language) I. Title.
A76.3.S67M38 2003
005.75’65—dc21

2002155887
Printed in the United States of America

10 9 8 7 6 5 4 3 2 1
C O N T E N TS
Acknowledgments xi

About the Authors xiii

Introduction xv

Chapter 1 An Overview of MySQL 1


Why Use an RDBMS? 2
Multiuser Access 2
Storage Transparency 2
Transactions 3
Searching, Modifying, and Analyzing Data 4
Ad Hoc Queries 5
Why Choose MySQL? 5
MySQL and JDBC 7
What’s Next 8

Chapter 2 JDBC and Connector/J 9


What Is JDBC? 9
What about ODBC? 10
Modeling Database Applications with JDBC 11
JDBC Versions 13
JDBC Driver Types 13
SQL Standards 14
Examining the JDBC Interface 15
The java.sql Package 15
The javax.sql Package 18
Understanding Connector/J 21
JDBC Support within 3.0.1 22
Obtaining JDBC Drivers 24
What’s Next 24

Chapter 3 Working with MySQL SQL 25


What Is a Database? 25
Database Models 27
Data Types 29
Designing a Database 29
Introducing MySQL SQL 32
Overview of MySQL 33
Creating Databases 34
Creating Tables 35
Inserts 39
Selects 40
SELECT Statement Extensions 42

iii
iv Contents

Updates 47
Deletes 50
Using SHOW 51
More on Tables 53
Transactions 55
Functions/Operators 56
Joins 56
NULL 59
What’s Next 59

Chapter 4 Installing MySQL, Java, and Connector/J 61


Installing MySQL 61
Linux Installation 62
Windows Installation 63
All Other Installations 63
Installing Java 64
Testing the Java Installation 64
Installing Connector/J 65
Testing the Connector/J Installation 66
What’s Next 66

Chapter 5 Using JDBC with Java Applications and Applets 67


Hello World 67
Loading the Connector/J Driver 69
Using DriverManager to Connect to a Database 69
Executing Queries Through Statement Objects 75
Using the ResultSet Object 78
Determining the Cursor Position 79
Moving the Cursor 79
Getter Methods 80
Primitive Getters 82
Closing the Objects 85
Making It Real 85
Our Main Function 88
The init() Method 89
The buildGUI() Method 89
Executing a Query with No Results 91
Deleting Database Rows 97
Updating Database Rows 99
CREATE TABLE 101
DROP TABLE 101
Disconnecting from the Database 103
Advanced ResultSet Manipulation 104
One Step Forward 113
One Step Back 114
Fast-Forward to the End 114
Contents v

Rewind to the Beginning 114


Goto Record 114
Freehand Query 115
Batches 115
Limiting Results 116
Database Warnings and Exceptions 117
What’s Next 118

Chapter 6 Achieving Advanced Connector/J Functionality with Servlets 119


Servlets 119
DataSource Connections 122
Execution Environment 123
Databases 123
PreparedStatements 124
Connecting to the Database 129
Determining the Submit Type 129
Displaying Data 130
Updating Data 132
Using Placeholders in a Loop 133
Using Placeholders in PreparedStatement 134
Using setObject/setBytes 136
Getting BLOBs 139
Joins 141
Updatable ResultSets 142
The Update Button Code 149
The Insert Button Code 150
Update Methods 152
Manipulating Date/Time Types 154
Methods for Retrieving a Value as a Date Type 155
Methods for Retrieving a Value as a Time Type 155
Methods for Retrieving a Value as a Timestamp Type 155
Handling BLOB and CLOB 156
Using Streams to Pull Data 158
Handling ENUM 159
Using Connector/J with JavaScript 161
What’s Next 163

Chapter 7 MySQL Type Mapping 165


Character Column Types 166
CHAR 166
VARCHAR 167
TINYTEXT 167
TEXT 167
MEDIUMTEXT 167
LONGTEXT 168
TINYBLOB 168
vi Contents

BLOB 168
MEDIUMBLOB 168
LONGBLOB 169
SET 169
ENUM 169
Using Character Types 169
Date and Time Column Types 171
DATE 172
TIME 172
DATETIME 172
YEAR 173
TIMESTAMP 173
Using Date and Time Types 173
Numeric Column Types 175
TINYINT 176
SMALLINT 176
MEDIUMINT 176
INT 177
BIGINT 177
FLOAT 177
DOUBLE 177
DECIMAL 178
Using Numeric Types 178
What’s Next 180

Chapter 8 Transactions and Table Locking with Connector/J 181


Understanding the Problem 181
MySQL's Transaction Table Types 182
The InnoDB Table Type 182
The BDB Table Type 184
Converting to Transactional from Nontransactional 184
Performing Transactions in MySQL 185
Using the autocommit Variable 185
Update Transactions 187
The SELECT/INSERT Transaction 190
Multiple Table Transactions 191
Foreign Key Integrity on Deletes 192
Ending a Transaction 192
Transaction Isolation 192
Dirty Reads 193
Phantom Reads 194
Nonrepeatable Reads 194
Table Locking 195
What’s Next 196
Contents vii

Chapter 9 Using Metadata 197


Using Database Metadata 197
Getting the Object 200
General Source Information 202
Feature Support 203
Data Source Limits 204
SQL Object Available 204
Transaction Support 204
The ResultSet Metadata 205
Getting Column Information 205
Other ResultSet Metadata 208
What’s Next 210

Chapter 10 Connection Pooling with Connector/J 211


What Is a Connection Pool? 212
Pooling with DataSource 213
Pooling with the DriverManager 218
DDConnectionBroker 219
What’s Next 221

Chapter 11 EJBs with MySQL 223


Multi-tier Architecture 223
Using Beans 225
EJB Types 225
The EJB Environment 226
Application Server Configuration 229
The Role of the Servlet 230
Entity Beans 230
Session Beans 234
Using the Beans 236
Adding a Query 238
Bean-Managed Persistence 240
ejbCreate() 241
ejbLoad() 242
ejbStore() 243
ejbRemove() 243
ejbFindByPrimaryKey() 244
Setter/Getter Methods 245
What’s Next 245

Chapter 12 Building a General Interface for MySQL 247


Tasks 248
SQL Exceptions 252
MySQL Connections 253
The Task Delegate 255
viii Contents

The Task Manager 255


Task Results 264
The Database Information Task 268
User Input for Tasks 270
The SQL Query Task 272
The Show Columns Task 275
The Insert Row Task 280
What’s Next 286

Chapter 13 Database Administration 287


Using the mysql Administration Application 287
Managing Users and Permissions 289
Changing Root 289
Adding Users 290
Limiting Resources 292
Configuring the Query Cache 293
Forcing a Cache 294
Understanding Log Files 294
Error Logs 295
General Logs 295
Binary Logs 296
Slow Query Logs 296
Maintaining Your Tables 296
Repairing Tables 297
Backing Up and Restoring Your Database 298
Restoring Data 301
InnoDB Table Types 302
DBD Table Types 302
What’s Next 303

Chapter 14 Performance and Tuning 305


Connector/J 3.0 Performance 305
Database Tuning 308
Server Options 308
Using RAID 309
Optimizing Tables 309
The MySQL Query Optimizer 310
Table Indexes 312
JDBC Tuning 313
Minimizing Data Requests 313
Keeping Consistent Connections 314
Handling Statements 315
Batching 316
Using Transactions and Locking 316
Defining the Architecture 317
Getting Data 317
Conclusion 318
Contents ix

Appendix A MySQL Development and Test Environments 319


Test Architecture #1 319
Test Architecture #2 320
Servlet Architecture 321
The EJB Architecture 323

Appendix B Databases and Tables 325


The accounts Database and Tables 325
The identification Database and Tables 326
Test Databases 327
Database Products 327
The Database Test 327

Appendix C The JDBC API and Connector/J 329


The java.sql Package 330
Array 331
BatchUpdateException 332
Blob 332
CallableStatement 333
Clob 335
Connection 335
DataTruncation 337
DatabaseMetaData 337
Date 343
Driver 343
DriverManager 343
DriverPropertyInfo 344
ParameterMetaData 344
PreparedStatement 345
Ref 346
ResultSet 347
ResultSetMetaData 350
Savepoint 351
SQLData 351
SQLException 352
SQLInput 352
SQLOutput 353
SQLPermission 353
SQLWarning 354
Statement 354
Struct 355
Time 356
Timestamp 356
Types 357
x Contents

The javax.sql Package 358


ConnectionEvent 359
ConnectionEventListener 359
ConnectionPoolDataSource 359
DataSource 360
PooledConnection 360
RowSet 360
RowSetEvent 362
RowSetInternal 362
RowSetListener 363
RowSetMetaData 363
RowSetReader 363
RowSetWriter 364
XAConnection 364
XADataSource 364

Appendix D MySQL Functions and Operators 367


Arithmetic Functions/Operators 369
Comparison Functions/Operators 372
Logical Operators 375
Control Functions 377
String Functions/Operators 379
Grouping Functions 384
Date and Time Functions 386
Other Functions 394

Appendix E Connector/J Late-Breaking Additions 397


Failover Support 397
Windows Named Pipes 398
Batch Processing Error Continuation 398
Strict Updates 399
Profile SQL 399
SSL 399

Index 401
A C K N O W L E D G M E N TS

Dedication
To my wife Diane, for all her support in my "geeky" endeavors, and to our
new daughter Lauren.
I would also like to dedicate this work to Monty, David, and the rest of the
fine group of developers at MySQL AB. Without their contribution to the
software community and dedication to free software and open source ideals,
this book would not have been possible.
--Mark Matthews

I would like to dedicate this book to my parents. Their ever-present love and
encouragement have made so many things possible.
—Jim Cole

This book is dedicated to the trinity: God, Jesus Christ, and the Holy Spirit.
—Joseph D. Gradecki

Acknowledgments
I need to acknowledge the patience and support of my beautiful and loving wife
and our boys. Thank you for the opportunity to be your husband and father.
Tim, thank you for the opportunities. Jim, welcome to this new adventure and I
look forward to many more in the future. Thank you to Liz Welch for the excel-
lent review.

xi
A B O U T T H E CAOUNTTHEO
NRTS

Mark Matthews is the creator of Connector/J and its predecessor MM.MySQL,


the Java JDBC driver for MySQL. Last year, he joined MySQL AB to further
develop Java support in MySQL. Mark specializes in Java, MySQL, XML, and
DHTML solutions and has architected major Web applications projects, includ-
ing a GIS-based retail analytics package. Mark has also taught classes in both
Java and UML.
Jim Cole is a senior software engineer specializing in Internet and knowledge
management systems. He is an active developer working in Java, C++, Perl, and
PHP. He also serves as a system administrator for several Web-based projects,
where his duties include custom software development, database management,
and security maintenance.
Joseph D. Gradecki is a software engineer at Comprehensive Software Solu-
tions, where he works on their SABIL product, an enterprise-level securities
processing system. He has built numerous dynamic, enterprise applications
using Java, AspectJ, servlets, JSPs, Resin, MySQL, BroadVision, XML, and
more. He has also built P2P distributed computing systems in a variety of lan-
guages including Java/JXTA, C/C++, and Linda. He holds Bachelors and Mas-
ters degrees in Computer Science and is currently obtaining his PhD.

xiii
Introduction

H
ave you ever been assigned a project and realized that you had no idea
how you were going to accomplish it? Many developers have experi-
enced this feeling when asked to interface their code with a database.
With a few exceptions, most developers were busy learning Lisp, linked lists,
and big-O notation during their formal education instead of learning the funda-
mentals of relationship database management systems. When the time comes
to interface their code with a database, they turn to a book like the one you are
holding.
Your challenge might be to write a Web-based system using servlets and Enter-
prise JavaBeans (EJBs) to transfer shipping records from the home office in
Bend, Oregon, to a satellite shipper in New Jersey. Or perhaps your father just
opened his new medical office and you volunteered to create a scheduling sys-
tem over the weekend.
Whatever the situation, interfacing an application to a database is one of the
most fundamental tasks a developer is required to perform. This book is
designed for developers who either have a pressing task ahead of them or who
are curious about how to read database information into their application.
By combining MySQL, the number-one open source database available, with
Java, the most portable language ever developed, you can create an undis-
putable champion. So, sit back in your desk chair with a hot chocolate and get
ready to supercharge your coding.
xvi I NTRO D U CTI O N

What’s in This Book


The primary goal of MySQL and Java Developer’s Guide is to provide a com-
prehensive approach to writing code from a Java application to a MySQL data-
base using the industry standard: JDBC. As you will see later in this
Introduction, the chapter titles indicate what area of database connectivity and
manipulation they cover. The chapters are ordered to reflect the JDBC specifi-
cation, but we aren’t here to simply describe the specification.
We wrote all of the material in the book to highlight how MySQL’s Connector/J
JDBC driver achieves the interfacing of MySQL with Java while maintaining the
spirit of the specification. With this in mind, we provide example code using all
major forms of Java development, including
■■ Applications
■■ Applets
■■ Servlets
■■ JSPs
■■ EJBs
As you work in Java and JDBC, you will see the true power of the specification.
You can write database access code in a Java application and move the code to
a servlet with little if any changes. In the case of EJBs and container-managed
persistence, we devoted a full chapter to dealing with database access without
the cumbersome details of SQL.
We designed the layout of the book to move you through the entire process of
writing Java code needed to access a back-end database. Developing the data-
base is one of the first things that you must accomplish in this process. While
we don’t delve deeply into the theory of database development, you learn how
to create databases in MySQL, administer those databases, and handle such
details as granting access permissions. From there, we take you into an exami-
nation of the MySQL Connector/J driver and how it accomplishes its goal of
portable database access. The remainder of the book steps you through Java
code that highlights how to accomplish database tasks such as the following:
■■ Querying and updating
■■ Handling ResultSets
■■ Using transactions
■■ Handling typing issues between JDBC and MySQL
■■ Working with metadata
■■ Addressing efficiency issues
MySQL and Java Developer’s Guide xvii

Once you’re familiar with these concepts, we present a complete application


that pulls it all together. Our application illustrates how you can create to a sim-
ple authorization service. Using a combination of JSP, servlets, and EJBs, the
service allows new users to create accounts, recall the account, and verify a
username/password combination. The system is designed to be interactive
using JSP pages, which are handled on the server using servlets. The JSPs can
be bypassed using the servlets directly. All of the critical information is kept on
the database for persistence and management needs.
After reading this book, you should know how to interface Java to MySQL and
be able to use the many examples for reference.

NOTE
All the code and examples in this book can be found on the the support Web site at
www.wiley.com/compbooks/matthews.

Who Should Read This Book


This book is written for Java developers who need to interface their code to a
back-end database. The book’s specifics deal with MySQL and Connector/J, but
this doesn’t limit the information because JDBC is designed to be portable
against many databases. If you aren’t using MySQL, you still find valuable infor-
mation.
You don’t need to know much about databases—we have included several
chapters that provide all of the basics necessary to create databases and make
sure they are operational. Keep in mind that we didn’t intend these chapters to
replace a good reference on MySQL, though.
We do expect that you are an experienced Java developer who is comfortable
with the language. This book explains a combination of Java delivery methods,
including applications, applets, beans, and EJBs; you may want to begin with
what you know best and expand from there.

The Technology Used


In this book, we use the latest Java Developments Kits (JDK) available from
Sun at the time of writing. The JDKs we used include J2SE 1.4.0 and J2EE 1.3.1.
The Java examples are used in a mixed environment, including Windows
2000/XP, Linux Mandrake, and Linux Slackware. For the most part, we devel-
oped the examples using simple text editors and compiled them using the Java
command-line compiler. However, all the examples should work just fine in an
IDE such as JBuilder.
xviii I NTRO D U CTI O N

Two different versions of MySQL are used throughout this book: 4.0.4 and
3.23.52. JDBC connectivity is handled using MySQL’s Connector/J driver, and
we cover both versions 2.0.14 and development 3.0.1.

Book Organization
The first four chapters of this book provide an overview of databases, JDBC,
and installation of the tools you will be using. The remainder of the book is an
in-depth guide to building database applications with MySQL, Connector/J,
JDBC, and Java.

Chapter 1: An Overview of MySQL


MySQL is one of the most popular open source database systems available
today, and it is used as the back-end data storage device for many personal
and corporate Web sites. Java is the most portable language in use today and
continues to be improved with each new release. In this chapter, we provide
a brief overview of each product and begin the discussion of how to interface
the two and thus allow Java applications to have access to a vast array of
information.

Chapter 2: JDBC and Connector/J


As shown in Chapter 1, JDBC facilitates the interface between Java and
MySQL. The JDBC specification defines the interfaces and classes necessary
for any Java application, applet, servlet, and so forth to make calls to an under-
lying database. Because the JDBC specification isn’t specific to any one data-
base system, manufacturers create JDBC drivers for their specific database. In
this chapter, we discuss the history of JDBC, how it started, and its progress
into a version 3.0 specification. We examine in depth the MySQL JDBC driver
called Connector/J, and look at its history as the MM.MySQL JDBC driver as
well as its future.

Chapter 3: Working with MySQL SQL


Before we delve into the concepts surrounding the interface between Java
and MySQL, this chapter provides a basic overview of databases and SQL.
Topics include basic concepts behind databases, simple database design,
database normalization, and data manipulation.

Chapter 4: Installing MySQL, Java, and Connector/J


MySQL and Java Developer’s Guide xix

All of the coding examples in this book are built using MySQL as the primary
database, Java as our coding language, and Connector/J, MySQL’s JDBC dri-
ver. Although the installation of these components isn’t overly difficult, this
chapter provides comprehensive instructions for obtaining all of the neces-
sary components and performing a step-by-step installation. We also provide
simple examples for testing the installation.

Chapter 5: Using JDBC with Java Applications and


Applets
This chapter is the first in a series on the use of Java to access a MySQL data-
base using JDBC. Some of the basic functionality discussed includes loading
the JDBC driver, connecting to a local or remote database, building JDBC
statements in preparation for queries, executing queries against the MySQL
database, working with ResultSets, and accessing MySQL-specific functional-
ity through JDBC.

Chapter 6: Achieving Advanced Connector/J Functionality


with Servlets
At this point, you’ve learned the basics, and it’s time to expand into the more
advanced topics. This chapter is designed to expand your understanding of
SQL, MySQL, and JDBC. The topics include updatable ResultSets, Prepared-
Statements, date/time types, BLOBs and CLOBs, and joins.

Chapter 7: MySQL Type Mapping


One of the fundamental issues associated with databases and programming
language is determining the correct mapping from one to the other. While
programming languages have a large variety of types, including simple ones
like integer, they also allow more complex ones, like classes. Databases, on
the other hand, are limited in their choices for the types of data that can be
stored. In the middle of this situation is the JDBC driver. This chapter dis-
cusses the types available on the MySQL database, how JDBC interprets
those types, and the resulting Java type produced by the mapping.

Chapter 8: Transactions and Table Locking with Connector/J


In a simple world, information is stored in a single table of a database. When
you have to update information or insert a new row, you can use a single
query. However, most modern databases store information across several dif-
ferent tables to increase the normalization of the tables. In this situation,
when you have to update information or insert new rows, you must write two
xx I NTRO D U CTI O N

queries instead of one. This chapter looks at inserting multiple pieces of infor-
mation into multiple tables, what problems can arise, and how transactions can
be used to solve these problems.

Chapter 9: Using Metadata


After a query is performed against a MySQL database, the information is
returned in a ResultSet object. This object includes all of the rows and columns
specific to the query performed. In many cases, additional information is
needed about the data, including the name of the columns in the result, the pre-
cision of the data in a float column, the maximum length of a column, and
maybe even information about the server from which the data was returned. In
this chapter, we discuss pulling metadata about both the database and a Result-
Set that contains information from a query.

Chapter 10: Connection Pooling with Connector/J


In many cases, a JDBC driver requires between 4 and 10 different communica-
tions with a database application before a connection can be established and
returned to the requesting application. If an application is constantly creating
connections, doing its business, and then closing the connection, the applica-
tion suffers in its potential performance. To overcome the connection perfor-
mance problem, you can use a connection pool. This chapter provides a
comprehensive introduction to connection pools, presents valuable statistics
for creating database connections, and demonstrates how to use the connec-
tion pooling mechanisms within JDBC.

Chapter 11: EJBs with MySQL


Enterprise JavaBeans (EJBs) provide the framework for building applications
that can handle the rigors of enterprise-level applications. In addition, EJBs can
be distributed across a network or a farm of servers. In this chapter, we cover
the basic EJB programming model, using DataSources and JNDI, and building
session beans to access MySQL. We also discuss container-managed persis-
tence and bean-managed entity beans.

Chapter 12: Building a General Interface for MySQL


All of the chapters to this point have featured relatively simple examples using
Java applications, applets, servlets, and JSP to illustrate the finer points of
accessing a MySQL database using Java and Connector/J. This chapter pulls it
MySQL and Java Developer’s Guide xxi

all together using a Certificate Authority application. Using JSP, servlets, and
EJB, the application shows how to create new accounts, request certificates,
and enable the verification of certificates. All of the information, including
the binary certificate, is stored in a MySQL database with multiple tables.

Chapter 13: Database


Administration
Once you have a good knowledge of the MySQL database system as well as
the fundamentals described in the previous chapters for accessing the data
from Java, you must learn some database administration basics. In this chap-
ter, we examine many of the functions within MySQL that benefit administra-
tors, such as granting/revoking permissions, providing security within the
server, and recovering from disasters.

Chapter 14: Performance and Tuning


Once the application is written and the information is safely sitting in a data-
base, the users get the final say on whether or not the application meets their
performance requirements. If the application isn’t running at an appropriate
level, you have a couple of options. First, you can profile the Java code to
determine where the application is spending the most time and then rework
the code associated with the problem areas. Second, you can tune the MySQL
server and create indexes for the database tables. In this chapter, we provide
the necessary information on performing these two options.

Appendix A: MySQL Development and Test Environments


We developed and tested all of the code in this book on several different test
architectures in order to provide a representative reference. This appendix
briefly describes those environments and lists the installed software. In addi-
tion, we offer some notes for reproducing the configuration.

Appendix B: Databases and Tables


In this appendix, we list all databases and tables used in the examples
throughout this book.

Appendix C: The JDBC API and Connector/J


This appendix is a comprehensive review of the entire JDBC API, with anno-
tations for Connector/J. Code snippets are provided to show at a quick glance
how to use the various interfaces, classes, and methods.
xxii I NTRO D U CTI O N

Appendix D: MySQL Functions and Operators


The list of MySQL functions and operators in this appendix will help you deter-
mine when the database should handle computations versus the application.
Each function and operator is described, and an example of its use is given.

Appendix E: Connector/J Late-Breaking Additions


The most current, up-to-date additions to Connector/J as it moves from gamma
to production version.
CHAPTER
1
An Overview of MySQL

I
n this chapter, we explain why you might choose to use a database system
with your software. We also provide an overview of the MySQL database
server and the Connector/J JDBC driver.
For many years, large corporations have enjoyed the ability to deploy relational
database management systems (RDBMSs) across their enterprise. Companies
have used these systems to collect vast amounts of data that serve as the “fuel”
for numerous applications that create useful business information.
Until recently, RDBMS technology has been out of reach for small businesses
and individuals. Widely used RDBMS systems such as Oracle and DB2 require
complex, expensive hardware. License fees for these systems are in the tens to
hundreds of thousands of dollars for each installation. Businesses must also
hire and retain staff with specialized skill sets to maintain and develop these
systems. Smaller enterprises have relied on systems like Microsoft Access and
FoxPro to maintain their corporate data.
Early on, during the explosive growth of the Internet, open source database
systems like mSQL, Postgres (now PostgreSQL), and MySQL became available
for use. Over a relatively short amount of time, the developers of these systems
have provided a large subset of the functionality provided by the expensive
commercial database systems. These open source database systems also run
on less-expensive commodity hardware, and have proven in many cases to be
easier to develop for and maintain than their commercial counterparts.

1
2 An Overview of MySQL

Finally, smaller businesses and individuals have access to the same powerful
level of software tools that large corporations have had access to for over a
decade.

Why Use an RDBMS?


Almost every piece of software that has been developed needs to persist or
store data. Once data has been persisted, it is natural to assume that this data
needs to be retrieved, changed, searched, and analyzed.
You have many options for data persistence in your software, from rolling your
own code, to creating libraries that access flat files, to using full-blown RDBMS
systems. Factors to consider when choosing a persistence strategy include
whether you need multiuser access, how you will manage storage require-
ments, whether you need transactional integrity, and whether the users of your
software need ad hoc query capability. RDBMSs offer all of this functionality.

Multiuser Access
Many programs use flat files to store data. Flat files are simple to create and
change. The files can be used by many tools, especially if they are in comma- or
tab-delimited formats. A large selection of built-in and third-party libraries is
available for dealing with flat files in Java. The java.util.Properties class
included with the Java Development Kit is one example.
Flat file systems can quickly become untenable when multiple users require
simultaneous access to the data. To prevent corrupting the data in your file, you
must lock the file during changes, and perhaps even during reads. While a file is
locked, it cannot be accessed by other users. When the file becomes larger and
the number of users increases, this leads to a large bottleneck because the file
remains locked most of the time—your users are forced to wait until they can
have exclusive access to the data.
RDBMSs avoid this situation by employing a number of locking strategies at
varying granularities. Rather than using a single lock, the database system can
lock an individual table, an individual page (a unit of storage in the database,
usually covering more than one row), or an individual row. This increases
throughput when multiple users are attempting to access your data, which is a
common requirement in Web-based or enterprise-wide applications.

Storage Transparency
If you use flat files in your software, you are also responsible for managing their
storage on disk. You have to figure out where and how to store the data, and
Another Random Document on
Scribd Without Any Related Topics
CHARTRES

No less than nine spires were originally designed and their towers
actually commenced. What a magnificent effect would have been produced
had they been completed! Standing on the high ground of the city, Chartres
with its clustering pinnacles would have been one of the wonders of
Christendom. The magnificent glass of the thirteenth century is so deep in
tone that upon entering the building one is conscious of a darkness that can
almost be felt, so much at variance with the effect of the interior of most
large French Cathedrals.
The two porches placed outside the transept doors are the subject of a
panegyric from the pen of Viollet-le-Duc. He considers them as the most
beautiful and harmonious additions ever made to an existing building, and
their architects proved themselves to be artists of the very first rank. No
more beautiful specimen of a portal of the thirteenth century can elsewhere
be found to exist; glorious and rejoicing in colour and in gold, and of
surpassing sculpture and full of impressive and solemn statuary.
RUE DE LA PORTE GUILLAUME, CHARTRES

Near Chartres there are two small towns which might well be taken in a
day’s excursion; both are connected with Chartres historically and both
have a certain interest of their own certainly not devoid of attraction to one
in search of antiquities. One is Châteaudun, whose fall during the war of
1870 was, as has been quoted above, the signal for the surrender of
Chartres; the other is Vendôme, the township of the ancient feudal county.
From Chartres it is Châteaudun that lies first in our road. It is a straight,
neat little town—most of the streets cut one another at right angles—and
the smoke of the Franco-Prussian war still seems to hover about the place;
one of its chief memories, indeed, is the great fight in October, 1870, when
a bare thousand franc-tireurs of the national guard kept the town for half a
day against a Prussian army of ten times their strength, and the quiet
market-square—now called the Place du 18 Octobre—was transformed into
a battle-field. All the heroism that the day called forth, however, could not
save the town from being sacked and burnt—the last of a long series of
conflagrations, lasting from the sixth to the nineteenth century, that has won
for the little town its cheerful, hopeful motto: “Extincta revivisco.”
Certainly Châteaudun has risen from the flames with a fresh lease of its
quiet life, but it has been completely modernised, and except for a few
narrow alleys sloping down towards the river, which would seem to have
escaped the general devastation, there is little that does not belong to to-day.
This is, however, making an exception of the Château overlooking the
Loire; a great exception, since at present all that there is to see in
Châteaudun consists in this square pile on the brow of the hill; the rest,
whatever it may once have been, is only a memory; and even the Château
itself hardly seems a part of the town, since it is not until we have left the
little white-painted streets behind that we realise its existence, and then it
comes as a gigantic surprise; a huge, square, turreted mass, on its platform
of rock, looking away over the rolling meadow lands, untroubled through
all the years of siege and conflagration. Thibaut le Tricheur, Count of
Champagne, built it in the tenth century; it was rebuilt in the twelfth
century, and again by its seigneur, the famous “Bastard of Orléans,” one of
the most devoted followers of Joan the Maid. Finally, under Louis XII.,
François d’Orléans-Longueville applied himself to fresh renovations, and
built the splendid façade overhanging the Loire.
Considering that the Duc de Vendôme has always been a title of some
importance in France since the early part of the sixteenth century, and the
Comtes de Vendôme a power in the feudal world before that, one might feel
rather surprised not to find the town itself presenting a more imposing
aspect. Vendôme is a picturesque place, but it is more of a long straggling
village than anything else, and it is only the ivied ruins on the cliff that take
one back—with a stretch of imagination, it must be confessed—to the days
of feudalism. Vendôme was originally, it is thought, a Gallic township under
the name of Vindocinum; it was then fortified by the Romans, evangelised
by Saint Bienheuré, and finally became the seat of a feudal count about the
end of the tenth century. In 1030 was founded the abbey of La Trinité,
whose church is one of the first “monuments” of Vendôme. It dates from the
thirteenth and fifteenth centuries; the beautiful Transition façade is well
worth notice, and so is the belfry tower, separated from the church and
tapering up to a tall stone spire. Inside the church there are some fine choir
stalls of the fifteenth century, of which the carving of the miséricordes is
very interesting in its variety and quaintness of design.
The Loire at Vendôme divides into several small streams, and in walking
through the town one appears continually to be crossing a succession of
bridges and coming upon fresh pictures of clear green water fringed by low-
roofed houses and dark lavoirs with their curtains of snowy linen. Outside
the town the river winds smoothly away past the cool quiet of the public
gardens, to join its tributaries and cut its silver channels through the distant
water-meadows.
“The route lay along the plateau until the heights were reached which
enclose the valley of the Loir; the road winds down to the river beside
hanging woods, red with autumn leaves not yet fallen, and crowned with a
ridge of firs. A corner is turned and Vendôme comes in sight, lying beneath
the shelter of the old ruined castle on the hill. As the horsemen enter the
town the people all come to the doors of their houses and gaze with every
sign of interested curiosity. There is an anxious expression in their faces.
They do not welcome, though they obey their visitors with alacrity. They
bring forth bread and meat and wine, and lay the tables for breakfast, but
good cheer they have none to give.”—The Times: “Prussian Occupation of
Vendôme.”
ORLÉANS, BOURGES, AND NEVERS

HE thought that the name of the city itself is most likely to call up
is that of the Maid who, born far away from Orléans, has taken its
name as a kind of surname.... We have got into a way of thinking ...
as if Orléans had its chief being as the city of the Maid.” Orléans certainly
does share with Rouen the chief honours of association with Joan of Arc,
the “Victrix Anglorum,” as she is described on a memorial tablet in the
Cathedral, and the town is equally full of monuments to her memory,
though the memory in this case is that of a great triumph, whereas at Rouen
it marks the last stage, captivity and death.
Orléans was the key of central and southern France, and if the English
once got possession of it they would certain overrun all the land south of
the Loire; hence its importance to France as a stronghold. Joan set out from
Blois late in April, 1429, in charge of a convoy of provisions for the
beleaguered city, and arrived opposite the town, on the left bank of the
Loire.
From November to the end of April the English had lain before the town,
and, although the inhabitants were not actually starving, provisions were
very scanty, and the bringing in of fresh supplies was practically an
impossibility, since the usual means of approach, the bridge across the
Loire, was blocked by the enemy, who occupied the outstanding fortress of
Les Augustins at the bridge, and on the right bank. On the Orléans bank the
English had built several strong bastilles, guarding the city and effectually
preventing any communication by means of the western highways. The
weak spot was on the east side, where the besiegers had one stronghold
only, the fortress of Saint Loup; and from this point Dunois, the general-in-
chief, and La Hire, the leader of Joan’s army, intended to effect an entrance;
but the Maid herself, with that love of directness which characterises her
whole career, desired to attack the English, not at their strongest, but at their
weakest point. Both wind and stream were against their ferrying over to
Saint Loup; and in the end Joan’s simple tenacity and childish belief in the
counsel of her “voices” carried the day. The army was sent back to Blois,
there to cross to the right bank and attack Orléans from the west, and
meanwhile she herself, the wind having turned, crossed in a boat by night
and entered the town with La Hire and Dunois. She was hailed by the
people of Orléans as an angel of deliverance, and lodged in the house of the
treasurer Boucher, near the Porte Regnart at the north-west angle of the city
walls; and from this vantage point Joan watched the enemy’s movements,
appearing from time to time upon the ramparts and bidding defiance to the
English, who, as was perhaps natural, retorted by showering insults upon
her. On May 4 she rode out in full state to meet her army which had arrived
from Blois. Three days later the great fight began. All this time the English
troops had scarcely moved a finger to hinder the French operations, but
when the enemy crossed the river by a bridge of boats and made a feint of
attacking the fortress on the left bank, retreating apparently in confusion,
the English sallied forth after them, thus provoking a real attack upon the
bridge fort. During the fray the girl-leader was wounded; never for a
moment did she give in, but stood in the fosse grasping the white banner—
sword she would not wield—and cheering on her companions; with the
result that by nightfall the position was gained, the English were driven out,
and Joan returned in triumph into Orléans by the bridge. The greater part of
her victory was now accomplished. On the following day the French forces
marched outside the walls of the town to meet the English line; but Talbot
and his men had not reckoned with what they, in the superstition of their
time, believed to be “a force not of this world,” and the morning light shone
upon their helmets and spears in full retreat towards the north. France was
saved, and a clear field was left for Charles the Dauphin—the gates of his
kingdom were flung open wide, that he might enter in and possess it.
ORLÉANS

But the greatness of Orléans belongs to an earlier day, before Joan heard
the voices in the Domrémy meadows, probably before Domrémy ever
existed. It was Attila the Hun who indirectly brought the town up the ladder
of fame. Aurelianum in the fifth century was a desirable stronghold, and as
such, Attila spied it afar from his Asiatic plains, and set out to conquer, and,
as one authority has it, to “vainly besiege” it, though Freeman inclines to
the opinion that “the business of West Goth and Roman was, in the end, not
to keep them (the Huns) out, but to drive them out.” However that may be,
Attila was eventually forced to give up his project, and Aurelianum
emerged from the struggle glorious and triumphant, to become the seat and
stronghold of kings, and, until its union with Paris in 613, the capital of a
separate kingdom. Since then it has been the scene of siege, martyrdom and
persecution, down to the days of the Franco-Prussian war, when it finished
an eventful history by a Prussian occupation in October, 1870, a sequel to
the battles of Patay and Bonbay.
Orléans is beautifully placed on a hillside overlooking the Loire. With
this physical advantage, and its long list of historical associations, one
cannot help feeling that it might have done better for itself, and have
become more than just a quiet, unobtrusive and rather dull city, with all its
monuments easily attainable. The Cathedral is an example of the last
lingering phase of Gothic architecture, and was rebuilt, so we are told—
after its destruction by the Huguenots—during the interval between 1600
and 1829. The building as a mass has great merit, for the architects have
made an effort to clothe it with dignity, and one feels that the church itself is
conceived in a spirit to make it, certainly at a distance, not unworthy of the
stronghold of Clovis and his successors.

THE HOUSE OF JACQUES CŒUR, BOURGES

The train which we took from Orléans to Bourges was slow enough to
enable us to look out, almost as easily as from a voiture, at the richly
wooded country. Here and there a small pyramidal church tower peeps out
from the trees, but, as a rule, there is little sign of life in this pleasant
country, and even the fields and the gorse-covered commons are bare of
sheep and cattle. This train-d’omnibus, in discharge of its functions as a
mail train, distributed letter-bags at every station. Here were waiting young
girls acting as postmistresses, many of whom had come from a considerable
distance, having ridden on bicycles, bare-headed, in the scorching sun,
along dusty roads, to deliver up their heavy loads and to enjoy a chat with
the travelling postman, who was evidently welcomed by them as bringing
all the latest bits of gossip along the line.
About a mile away there is a very beautiful view of the town, and the
general effect is a grey one. Roofs and houses—the latter perhaps originally
built of yellow-white stone—have all weathered to a beautiful grey, and
there is an air of mediævalism about the place. Bourges, indeed, like many
other towns in France, goes back to early days for its greatness, and belongs
far more to the past than to the present. The fifteenth century saw it at the
height of its fame as a king’s residence; Charles VII., perhaps finding the
more northerly towns too hot for him during the English occupation, took
up his abode there and became for the time being “King of Bourges”; and
Louis XI. founded a university in the town.
Here was born the famous Bourdaloue, and Boucher, the painter of
Versailles before “le Déluge,” Boucher who was

“a Grasshopper, and painted—


Rose-water Raphael—en couleur de rose,
The crowned Caprice, whose sceptre, nowise sainted,
Swayed the light realms of ballets and bon-mots;
Ruled the dim boudoir’s demi-jour, or drove
Pink-ribboned flocks through some pink-flowered
grove,”

and who now, his Grasshopper days ended, lies buried beside his mother in
the Church of Saint Bonnet.
BOURGES

Perhaps the principal interest of old Bourges centres in the name of


Jacques Cœur, the merchant prince, “a Vanderbilt or a Rothschild of the
fifteenth century,” who in his days of prosperity built a great house on the
hill-side where his native town stands. Cœur, we are told, founded the trade
between France and the Levant; later he became Master of the Mint in
Paris, and one of the Royal Commissioners to the Languedoc Parliament.
He was three times sent on an embassy to foreign powers, notably to Pope
Nicholas V. Charles VII., weak, unstable, and always in need of money,
relied on him absolutely, but with the usual characteristics of a weak master,
was one of the first to desert and despoil him of his wealth when occasion
offered. The beginning of the end came through a disgraceful and
apparently quite unfounded accusation against Cœur at the time of the death
of the famous Agnes Sorel, whom he was accused of poisoning. Jacques
was too prosperous not to have enemies, and these were, as usual, prompt to
use every opportunity against him. The first steps taken, calumnies of all
kind poured in to defame the man whom France had once delighted to
honour, and the rest of his career is a strange mixture of exile, mysterious
captivity, and equally mysterious escape, honourable reception in Rome,
and friendship with the Pope; the last scene of all, perhaps the strangest and
most foreign to all idea of a peaceful, prosperous merchant—for here we
see him in command, not of a fleet of trading ships laden with merchandise,
but of vessels of war sent against the Turks by Pope Calixtus III. Rumour
has it that, far from dying in poverty and sorrow, Jacques Cœur, at the end
of his life, had acquired greater riches than when at the zenith of his fame in
France, but the fact remains that he died in exile, with a cloud over his
memory which was not cleared away until many years after, when popular
favour again smiled on his name, and he became, what he remains to this
day, the citizen-hero of Bourges.
There is a very charming description—too long to quote here—in Mr.
Henry James’ “Little Tour in France” of the house of Jacques Cœur; and
one point of interest attaching to it is that it is built upon the old defences of
the town, and at the back are many considerable remains of solid Roman
bastions.
It is one of the most beautiful types of a fifteenth-century town-house
that can possibly be imagined—a veritable remnant of the ancient
prosperity of Bourges, of a time when such houses were no uncommon
feature in the streets—when men who had made their fame and fortune
loved to build for themselves a beautiful home in their native town, and
enrich it with every conceivable ornament. Modern nouveaux riches indeed
do the same, though perhaps not in their native place, where their memory
as butcher or baker might, in their eyes, tell against them; but the difference
between their “mansions” and the hotel of Jacques Cœur is the difference
between an age when the Renaissance was in its early freshness and an age
when it has suffered the degradations of many modern horrors in the style
that is popularly designated “handsome.” No one looking upon the delicate
sculptures, the wonderful wood carving, the courtyard with its cloister, the
lovely porticos and galleries, can doubt the taste of the man who built and
lived in this “maison pleine de mystères.”
THE MUSÉE CUJAS, BOURGES

The Cathedral of Bourges, which, as Freeman points out, is essentially


French, although at the head of the Aquitanian churches, is well seen in
approaching the town, where it rises above a base of grey tiles and warm
white walls—a long flank of choir and nave, unbroken by transepts. The
thrust of the heavy vaulting is stopped by a perfect forest of flying
buttresses, between whose walls are built chapels, either for chantries or
family monuments. From inside the town it is not much in evidence until
one ascends the Rue Royale, where one comes upon it quite unexpectedly at
the end of what Mr. Henry James calls a “short vague lane,” somewhat in
the same manner as one comes upon St. Paul’s bursting into view at the top
of Cheapside.
The absence of transepts accounts naturally for the want of any central
tower or lantern, and as there are no heavy transept pillars supporting the
arches at the crossing, to intercept the view, the elevation of the Host is
visible to every worshipper, and the eye travels in one sweep through nave
and choir to the beautifully jewelled windows of rich old glass, ranging
from the twelfth to the seventeenth century. The east terminal vaulting
springs so low as to mask part of the side-lights of the apse. This is also
very noticeable in the east end of Sens Cathedral, the beauty of whose
windows is marred by the vaults cutting across the heads of the lights. At
Bourges, however, the spandril or cheek of the vault is pierced by a foliated
light, showing a certain amount of the window behind, and thus taking
away the appearance of depression in the low springing vaulting of the
apse.
It is easily recognised that in point of historical importance Nevers, in
comparison with some of its neighbours, dwindles almost into
insignificance, and to the traveller coming from Orléans and Bourges, fresh
from the scene of the triumphs of Joan of Domrémy, and from the seats of
French kings when France was at the height of her power, there may be a
slight sense of disappointment at not finding the same historical “lions” at
Nevers. History, though not passing over the town entirely, has only
touched it with a gentle hand, and Nevers, though possessed of plenty of
material for making itself a name, has never really risen very far above
being the capital of the Nivernais. It existed in Roman days under the Celtic
name of Noviodunum; Cæsar made use of it as a military depôt in his Gallic
campaign, and thought the town was of sufficient importance to be a
storehouse for the imperial treasure; its countship dates from the tenth
century, and it became the seat of a bishop, although later than many of the
Auvergne cities. Yet the counts of Nevers never made a stir in the world, as
did Odo and Thibaut of Chartres, or the Fulks and Geoffreys of Angers, and
nowhere on its ecclesiastical roll do we find a name like Hilary of Poitiers
or Martin of Tours. Despite these early deficiencies, however, Nevers has
much to interest the casual visitor, and there are four principal attractions—
the Cathedral of St. Cyr, the Romanesque church of St. Etienne, the ducal
palace (now the Palais de Justice), and the Porte du Croux.
THE HÔTEL-DE-VILLE, NEVERS

The early church of St. Etienne, begun in 1063, is a fine example of a


Romanesque building. It is also a very severe example, with a nave of
round-headed pier arches, double-arcaded triforium and small clerestory
lights. The bays of the nave are modified in the choir by the pier arches
being stilted, by a small triple-lighted triforium, and by more importance
being given to the clerestory windows. There are, also, monolithic columns
and hollow-necked capitals, which are unusual in France. The church is
covered by a barrel vault, the crossing of the transepts being crowned by a
dome. Mr. Spiers, in his book on “Architecture East and West,” says: “The
French builders of the South of France have always had the credit of being
the originators of the barrel vault, with its stone or tile roof, absolutely
incombustible, lying direct on the vault; to them also, I contend now, we
owe the development of the dome, with its pendentives set out in a manner
peculiar to themselves, and in no way corresponding to those found in the
East.”
The Cathedral of St. Cyr is the only church in France—with the
exception of Besançon—which possesses an apse at both the east and west
ends. St. Gall in Switzerland, Mittelzall, Laack and many other German
churches show this remarkable plan of a western tribune or paradise. In
some instances it was used as a tomb-house, with entrance from without by
means of a staircase. In the old basilicas, however, the tribune was not
unfrequently at the west end, so that the officiating priest could at the same
time face the east and also his congregation. The crypt at the west end, with
its fine Romanesque capitals, is very interesting, and dates from the early
part of the eleventh century, being about contemporary with that of the
Cathedral of Auxerre. The original church, with its two transept arches of
the same date, was lengthened eastwards in the thirteenth century, and later
on had the further addition made of a choir with an apsidal termination; the
chancel and nave are not separated by transepts, but the two merge quietly
into each other by simple contact.
PORTE DU CROUX, NEVERS

One afternoon, while contemplating this strange church, our attention


was diverted from arch and apse by the rustle of a small bridal procession
entering by a side door and being received by a priest who was waiting at
an altar in one of the chapels. After some formalities of examining the
certificate of civil registry, the ceremony began; and it was very interesting
in its brevity and friendliness. In the English church the priest addresses the
principals, with a kind of austere familiarity, by their Christian names, be
they princes or paupers. But here such a liberty is rendered impossible by
the natural social politeness of the French, and the contracting parties are
reminded of their marriage obligations under the courteous appellations of
Monsieur and Mademoiselle.
The ducal palace is quite close to the Cathedral. “We find,” Freeman
says, “the two great central objects, State and Church, sitting becomingly
side by side.” The ducal days of Nevers date only from the end of the
sixteenth century, when François Ier, with his usual love of display,
bestowed a peerage upon the Nivernais. Before this its feudal overlords
went by the more mediæval title of count, and the palace (built a century
before the count became a duke) has reared itself upon the foundation of
their ancient stronghold. The fourth attraction of Nevers, the high square
gateway tower known as the Porte du Croux, may also be regarded as a
relic of feudal days, seeing that it dates from 1398, and was evidently part
of the town’s defences. It is a noble specimen of mediæval defence, a tall
gateway tower, protected, like the Porte Guillaume at Chartres, by its
ancient fosse—long lancet openings running up above a low round archway
and two pointed turrets flanking the hatchet-shaped central roof, with the
treacherous line of machicolation below. In the middle of the sixteenth
century Nevers passed to an Italian master, one of the Gonzagas of Mantua,
from whom, a hundred years later, Mazarin bought it back again, and left it
at his death to the Mancini family, who held it until the Revolution.
Most French towns nowadays fill their shops with a display of local
pottery, good, bad and indifferent; the industry of Nevers, however, is an
old-established one, dating from the occupation of these very Gonzagas,
who came from a land where the faïence industry, as well as glass-blowing,
was fully developed as a fine art, and who founded in their domain a school
of artists which should teach their secrets to France. The industry has
remained in the town ever since, and some of the modern work is very
charming, with its curious trade-sign, the little green arabesque knot or
nœud vert, which some fanciful spirit designed for the sign of Nevers.
MOULINS, LIMOGES, AND PÉRIGUEUX

ROM Nevers an expedition to Moulins is quite practicable, and the


traveller en route to Limoges may think it worth his while to pay a
visit to this town, which stands as a monument to the fallen house of
Bourbon. In the fourteenth century the dukes of Bourbon made Moulins
their residence, and stayed there until the desertion of the Constable to the
cause of Charles V., when the city was annexed by the French king,
François Ier, in an access of righteous indignation. The “Tour de l’Horloge,”
which is the main feature of the town, and looks more like a Dutch belfry
than a French design, formed part of the old château belonging to this same
Constable; and it may be supposed that not only were his lands confiscated,
but his castle destroyed, by way of punishment for his alliance with the
English king and the German emperor.
The story of this Constable de Bourbon is an interesting one. He
belonged to the Montpensier branch of the Bourbon family, and in 1505
married Suzanne de Beaujeu, heiress of the reigning line, so that the title of
duke and the rich Bourbon estates passed into his possession, and therewith
Charles became one of the most brilliant figures in an age of brilliancy and
magnificence. His handsome person and military talents had even in early
youth gained him a place amongst the foremost gentlemen of France; but
his marriage brought him such an access of wealth and influence that even
Louis XII. trembled for the safety of his throne, and refused to risk any
increase in his popularity by giving him command of the Italian army. In
1515, however, when the Duc d’Angoulême came to the throne as François
Ier, Bourbon was made Constable of France, and for a time seemed to have
attained to all that Fortune could give him. He was the close friend of the
king, and in an era of lavish display that came with the first François, and
did not wholly disappear until it was swept away by the hand of the
Revolution, no favours seemed too great, no honours too high, for the
brilliant and much-envied favourite. To such a height did Charles de
Bourbon reach, that one can, indeed, hardly wonder at his fall, which was
bound to come sooner or later, and when it did come was all the greater, all
the swifter, from the very might of his power at court. The mischief arose in
the first place through the jealousy of the king’s mother—reports and
scandals were in the air, and François was not slow to take note of them—
and of the growing distrust of his favourite at court. Quarrels arose between
King and Constable. Presently the evil reports took definite shape, and grew
into the grossest of insults; and as soon as it was seen that Bourbon had lost
the King’s favour all tongues were loosened against him. Added to these
troubles, he was engaged in a lawsuit with the mother of François, the
Duchess d’Angoulême, who on the death of his wife Suzanne claimed the
heirship to all his estates and fortune. As may be imagined, on the principle
of striking a fallen man, the case went against him, and the great duke
found himself friendless and penniless, with large sums owing to him from
the State, but with little hope of payment. Men in those days were not over-
chivalrous, and the idea of clinging still to an ungrateful, ungenerous
sovereign who had cast him off like an old glove did not commend itself to
a nature like that of Charles de Montpensier. He resolved, since France
would have none of him, to try his fortune with Germany, and accordingly
joined the cause of Charles V., to whom for a time he gave his best service,
and then, finding the imperial promises, too, like the proverbial pie-crust,
determined to carve out honours for himself and find a kingdom in Italy. He
marched to Rome with a division under his command, and made a bold
attack upon the city walls, but an arrow from the ramparts, shot, so one
story goes, by Benvenuto Cellini, the famous sculptor and court musician to
the Pope, put an end to his ambition, and the Constable died in harness
outside the walls of Rome at the very outset of his gallant attempt to cast off
the yoke of kings and make his fortune by his own sword.
Of Bourbon’s château there remains only the tower bearing the curious
name of the Mal-Coiffée, and a Renaissance pavilion—an appendage found
in the castle of every great noble of this time.
In the eleventh century Moulins was one of the more southerly fortresses
to hold out against William of Normandy. It had been commanded by a
certain Wimund, who surrendered it to Henry, the French king. As an
important outpost it was garrisoned strongly and put under the command of
Guy of Geoffrey, Count of Gascony, presently to become William VIII. of
Aquitaine. The Norman duke, however, was advancing upon Arques, which
was within an ace of surrender from hunger, and with little difficulty he
obtained terms from the garrison. News of this defeat soon flew to Moulins,
and its commander seems to have been instantly seized with an access
either of panic or of prejudice—the two bore a curious relation in those
days—and without giving the Normans time so much as to come within
sight of the town, he withdrew his garrison and left Moulins with all speed.

MOULINS

The Cathedral at Moulins has a curious misfit of nave and chancel. The
former is of the thirteenth century, with a high clerestory and rather low
triforium arches; the latter is Flamboyant, with a flat wall termination to the
east end, and seems to have been built without any regard to the pre-
existing nave; at any rate, the main piers do not meet, and a small bay of no
particular style is introduced literally as a stop-gap.
An excellent hotel—the “Central”—makes Limoges a convenient
stopping-place on the southern road, irrespective of its attractions to those
interested in faïence and enamel work; but there are plenty of other interests
within the town, and Limoges may, indeed, speak for itself in this respect,
by reason of its standing on a hill, overlooking a river, and containing, in
the old quarter at least, ancient houses and crooked streets enough to satisfy
any craving for the picturesque. The town slopes up a hill rising from the
Vienne, and really divides into two distinct parts, ville and cité; the ville is
the newer town straggling up the slope, while the cité, the original camping-
ground of the Lemovices, occupies the quarter near the river. So distinct
were these two in the Middle Ages that we even read of war between them
as between two separate states, the ville led by the abbot of Saint Martial,
the cité by the bishop. The great church of the river quarter is the Cathedral
of Saint Etienne, built, so tradition has it, upon the remains of a former
church erected by Saint Martial, and dating from 1273-1327, with a few
later alterations. The west end terminates in the substructure of an old
Romanesque campanile, resting on pillars. “The lowest story,” says
Freeman, “after a fashion rare but not unique, stood open. Four large
columns with their round arches supported a kind of cupola.” Under the
choir is a crypt, dating from the eleventh century, and thus at each end of
the later church is a relic of an older time.
Limoges had formerly been favourable to the English, but since the
dukes of Berri and Bourbon had laid siege to the town, and had been aided
by Bertrand du Guesclin, the inhabitants, including the bishop and the
governor, gave up their somewhat wavering allegiance and turned to
France. On hearing of this defection the Prince of Wales flew into a great
passion and “swore by the soul of his father, which he had never perjured,
that he would not attend to anything before he had punished Limoges; and
that he would make the inhabitants pay dearly for their treachery.” The
price they had to give was the safety of their city. Edward marched upon
Limoges from Cognac with a large force; but the new masters had
garrisoned the town so strongly that it was impossible to take it by assault.
He therefore resolved upon another and a more terrible way. He undermined
the fortifications, and set fire to the mine, so that a great breach was made.
Froissart describes the inhabitants of the town as very repentant of their
treachery, but adds poignantly that their penitence did little good, now that
they were no longer the masters; and certainly it was not rewarded by
mercy. The English troops rushed into the breach and poured down the
narrow streets, massacring right and left, plundering and burning, sparing
neither women nor children; and when the Prince at last turned back to
Cognac, he left behind him ruin and desolation where, a few days before,
had been strength and prosperity. During this terrible time the Church of
Saint Etienne happily escaped from damage, although all the rest of the old
town—“old” even in 1370—seems to have been destroyed. An interesting
reminder of more modern history remains in the name of one of the streets.
The Cathedral is connected with the Place Jourdan by the “Rue du 71ième
Mobiles”; and this street is so named in recognition of the valour shown by
this regiment in the field, and in the memory of those killed during the
Prussian war. It is an assurance that their heroism and endurance in a
hopeless struggle are not forgotten, and that an equal devotion to their
country will be shown, should the need arise, by succeeding generations of
their fellow-citizens. Monuments are not readily subscribed for, nor are
places where they may be erected easily found. A permanent testimony to
the gallant services of a regiment might be borne by calling a street after its
name. London accorded a great welcome to its volunteers at the termination
of the Boer war. Is there any street or place called after the name of the City
Imperial Volunteers?
LIMOGES

In a cathedral city like Limoges, where the church itself has a good deal
of interest and the town is not devoid of attraction, one is not readily
inclined to place its industrial interests very high on the list of things to be
seen; yet the fact remains that in this particular place the chief industry is
closely bound up with the town’s history. The Limoges school of enamel
workers had attained celebrity as early as the twelfth century, when the
champ-levé, or engraving process, was in vogue, the ground-work of the
plates consisting of graven copper and the cavities filled in with enamel.
This kind of work may well be seen in Westminster Abbey upon the tomb
of Aymer de Valence, Earl of Pembroke. In the fourteenth century France
borrowed from Italy the art of transparent enamelling, which the artists at
Limoges developed into enamel-painting, and this branch was carried on at
Limoges for upwards of two centuries, until it fell into decay under Louis
XIV. and gave place to the modern miniature style.
Under François Ier this art of enamel-painting attained to a high degree
of perfection. The sixteenth-century taste inclined always towards the
brilliant and magnificent, and the same love of display and richness which
showed both in dress and in architecture found also expression in the art of
enamelling. One of the most famous artists of this school came from
Limoges, whence he was known as Léonard Limousin. His work became
the pattern of excellence after which all lesser artists strove. “While some of
the works were executed in brilliant colours, most of them were in
monochrome. The background was generally dark, either black or deep
purple, and the design was painted en grisaille, relieved, in the case of
figure subjects, by delicate carnation. The effect was occasionally
heightened by appropriate touches of gold, and in many of the coloured
enamels brilliancy was obtained by the use of silver foil, or paillon, placed
beneath a transparent enamel.”
At Périgueux we seem to have left Northern France in the far distance
and to have taken the first definite step into the Midi. The architectural
pilgrim as he wanders southward is conscious of the existence of two
distinct styles, possessing features dissimilar in construction and design; in
one case he finds barrel-vaulted churches, in another large churches roofed
with pointed domes, whose origin it is difficult to determine. Of the latter
type the church of Saint Front is a notable instance. It rises above the old
quarter, which occupies the centre of the town, the modern portion, quite
distinct from the rest, as was the case at Limoges, sloping up the hill, and
the remnant of the old Roman city fronting the river. The original Vesunna
of the Petrocorii stood on the left bank of the Isle; the Roman Vesunna
crossed to the other side, and is now represented by the ruins of an
amphitheatre, dating from the third century, and some second-century baths.
The old Château Barrière is also built on Roman fortifications, and two of
the Roman towers still remain, besides the “Tour de Vésone,” which was
probably part of a pagan temple.
PÉRIGUEUX FROM THE RIVER

It is a curious fact that here the ancient remains of the Roman city should
be so much more prominent than is usually the case. At Bourges we saw the
house of Jacques Cœur built upon a Roman foundation, and many other
places keep, in part at least, their Roman walls; but Périgueux has Roman
remains which absorb quite half the interest aroused by the city on the Isle
—the other half being devoted to the church. From the site of the Gallic
Vesunna, on the left side of the river, the Tour de Vésone is the foremost
object, so old that, as Freeman says, it looks almost modern. “It is a singular
fact that, while a mediæval building can scarcely ever be taken for anything
modern, buildings of earlier date often may. The primeval walls of Alatri
might at a little distance be taken for a modern prison, and this huge round,
it must be confessed, has to some not undiscerning eyes suggested the
thought of a modern gasworks.” Then the partly mediæval Château Barrière
attracts notice, dating at its latest from the fifteenth and sixteenth centuries,
and by its name recalling one of the noblest families of mediæval Périgord.
With the rise of the abbey of Saint Front, a new town arose also, and the
old quarter shrank up within itself, remaining still the abode of the nobles
and gentlemen and the clergy of Saint Etienne, but yielding the real
precedence to the vigorous new puy higher up the hill. “Here, as in some
measure at Limoges, the tables are turned. The ville stands apart on the hill,
with the air of the original cité, while the real cité abides below, putting on
somewhat the look of a suburb.” Even Saint Etienne, the old Cathedral-
church of La Cité, has, owing to its partially ruined condition, practically
renounced its importance both in intrinsic position and in external
appearance. The great tower, which once stood at the west end, has gone
entirely; the cupolas which crown each bay show the relation to those at
Saint Front, and in place of the eleventh-century apse stands a flat wall,
terminating in a choir of a century later.
The church of St. Front is “the only domed church in France with the
Greek cross for its plan.” The original building is said to have been
consecrated in 1047 by the Archbishop of Bourges and burnt down in a
great fire in 1120. It was not until after this date that the five-domed church
and the tower on the west side were constructed. “By this time the Church
of Saint Mark at Venice was completed, as far as its main structure was
concerned, and already the panelling of the walls with marble and the
decoration of its vaults and arches with mosaic had made some progress. It
was one of the wonders of Europe, and the idea of copying its plan and
general design would appeal at once to a race of builders who for more than
a century, as I shall prove later on, had been building domed churches
throughout Aquitaine, who were perfectly acquainted with their own
methods of building domes and pendentives, and therefore would not be
obliged to trust to foreign workmen to execute them.”—MR. R. PHENÉ
SPIERS.
ST. FRONT, PÉRIGUEUX

It would be quite out of our province to follow out Mr. Spiers’ arguments
in support of this theory, as it would lead us into the entangled byways of a
discourse on methods of “bedding” and centring arches and pendentives.
Suffice it to say that he clearly points out the difference which exists
between French and Byzantine domes, capitals and voussoirs and the
prevalence of the Aquitaine style, and on this evidence maintains that
French, and not Greek or Venetian architects, built the abbey church of
Saint Front. This conclusion is also supported by Viollet-le-Duc, who
expresses his opinion that Saint Front was undoubtedly built by a
Frenchman who had studied either the actual Church of Saint Mark at
Venice or who had had opportunities of seeing the design of the Venetian
architects. Its general conception, it is true, was Venetian and quasi-
Oriental, but its construction and details do not recall in any way the
decorative sculpture or method of building which obtained at St. Mark’s at
Venice. As to the ornament, it belongs to the late Romanesque style.
Saint Front must indeed have appeared a strange erection and unique in
conception amongst its sister churches, and no doubt exercised a great
influence over the builders of churches north of the Garonne in the eleventh
and twelfth centuries. The infusion of Oriental art into this part of the
country is explained by the distinguished French archæologist, M. Félix de
Verheilh, as partly due to the presence of Venetian colonies established at
Limoges. He says that the commerce of the Levant was carried into France
and into England along trade routes existing between Marseilles or
Narbonne and La Rochelle or Mantes. The landing of Eastern produce at
these ports on the Mediterranean and its carriage overland to the north-
western seaboard of France was rendered necessary to protect it from the
Spanish and Arab pirates who infested the coasts of Spain and Africa, and
also to avoid the risk of storms and heavy seas of the Straits of Gibraltar.
ANGOULÊME AND POITIERS

NGOULÊME has at a distance more the appearance of an Italian


than of a French town. The heavy red pantiles, the campanile and
dome of the Cathedral, the little terraces sloping up the hill, all
recall the southern towns; but the river with its fringing poplars finally
proclaims the city’s nationality. There is nothing of especial interest to be
seen in the town itself. Angoulême—Ecolisma of the Gauls—has of course
had its history; it suffered pillage by Visigoth and Norman, was annexed by
England, re-taken by France, occupied again by the English, and finally
made over to its rightful sovereign in 1369.
During the Hundred Years’ War Angoulême was in the possession of the
English, and under the governorship of Sir John Norwich surrendered to
France. The Duke of Normandy lay, we are told, “for a very considerable
time” before the town, and the inhabitants waited daily for the Earl of
Derby, who was to relieve them, but who showed no signs of approach. The
French made a raid upon the English cattle under the guidance of the
seneschal of Beaucaire and captured not merely the beasts, who—strange
laxity—were pasturing outside the walls of the town, but several of the
English who rushed out to recover their possessions. Finally the governor
began to lose hope; Derby was nowhere within reach, the French gave no
signs of withdrawal, and worse than all, the townsfolk began to murmur and
to declare as far as they dared for the enemy. Norwich and his immediate
followers found themselves in some danger; but by a clever stratagem they
escaped from surrendering themselves to Normandy. A truce was called,
and under cover of this the governor and his friends sallied quietly forth
from the gates, passed through the entire French army, without hurt, and
took the road to Aiguillon before the enemy had realised what they were
about. Meanwhile the disaffected within the town readily gave themselves
up to the Duke, and received his mercy.
Here, however, as at Nevers, an up-and-down history has left little mark
upon the town, and Freeman’s criticism is no more than the truth: “Except
we went on purpose for the view, we should hardly go to Angoulême at all.”
Saint Pierre at Angoulême is another example of the domed church that we
left at Périgueux; but while the cupolas carry on the same half-Byzantine
idea as prevails in Saint Front, the tower at the north transept brings in a
train of thought which is distinctly Italian; moreover, at Périgueux all five
cupolas are well seen from the outside, whereas here only one appears, to
balance, or rather to contrast with, the north tower. Once inside the church,
however, the other domes appear, roofing over the nave, which is without
aisles, after the manner of the Angevin churches. In its original form the
Cathedral of Saint Pierre was begun early in the twelfth century—about
1120—but it has been twice restored, once in 1654 and once, in the middle
of the last century, by M. Abadie.
It was planned simply with a nave roofed by four cupolas and a choir
with four radiating apsidal chapels. Later on in the century the love of
building places of worship larger and more suited to the growing desire for
an enriched ceremonial and elaborate ritual resulted in the addition of
transepts surmounted by towers, which gave to the Cathedral of Saint Pierre
at Angoulême the distinction of being one of the first, if not the first, of
domed churches built on the plan of a Latin cross. Of the two towers only
one, the northern tower, exists to this day, the southern transept being
roofed by a flat conical dome. Certain further additions were made about
the same time, such as the western façade with its sculptured portal. The
black lines of the ashlar work, as if ruled with a lead pencil, detract very
much from the impressiveness of the interior, as they give undue emphasis
to the horizontal joints and arrest the eye in its first natural flight from floor
to vault.
Saint Pierre at Poitiers is a church of a very different description. Certain
characteristics it has which connect it with the Angevin style, but unlike
most of the Angevin churches, it has aisles throughout. From the outside the
appearance is that of a single mass, long and low, and very wide, for the
aisles are nearly as broad as the nave; as at Bourges, there is no central
tower at the crossing; but then at Bourges we have a great French church, a
mighty mass rising sheer up from the ground, unbroken by any transept;
here at Poitiers there are transepts, but the line of their towers comes below
the line of the roof, and the effect given is one of length without height.
Height is also wanting in the two unfinished and unequal west towers, and
the east end literally falls flat, by reason of its bare terminal wall; the apse,
to which one grows so accustomed in a French church, is seen only from
the interior. It is oblong in plan, showing, as M. Viollet-le-Duc points out,
no sign either of choir or sanctuary. The transepts are more like side chapels
with altars on their eastern walls. There is no sign of northern influence, and
the church is in many of its features unique and without imitators. Certain
details of construction bring it into line with St. Maurice at Angers; it is an
ordinary example of the churches of Poitou, with their three naves of equal
height and Byzantine cupolas.

ANGOULÊME

To the south of the Cathedral lies what alone would make Poitiers worth
a visit, without the other churches which call for notice—the little Temple
Saint-Jean, said to be the oldest baptistery in France, and dating probably
from the fourth century. Once inside, we can realise the position of the
officiating priest and the place occupied by the rooms where the converts
disrobed themselves and whence they were conducted to the central basin,
fed by a continual stream of water, where stood the bishop, the typical
representative of the first Baptist. Freeman says: “It is the one monument of
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like