Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (2 votes)
11 views

(Ebook) MongoDB for Java developers design, build, and deliver efficient Java applications using the most advanced NoSQL database by Francesco, Marchioni ISBN 9781785280276, 9781785286292, 1785280279, 1785286293 - Read the ebook online or download it as you prefer

The document provides information about various ebooks available for download, including 'MongoDB for Java Developers' by Francesco Marchioni, which focuses on building efficient Java applications using MongoDB. It includes links to download the full version and other related ebooks. Additionally, it features details about the author and reviewers, as well as a comprehensive table of contents for the book.

Uploaded by

soopinjusys20
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
11 views

(Ebook) MongoDB for Java developers design, build, and deliver efficient Java applications using the most advanced NoSQL database by Francesco, Marchioni ISBN 9781785280276, 9781785286292, 1785280279, 1785286293 - Read the ebook online or download it as you prefer

The document provides information about various ebooks available for download, including 'MongoDB for Java Developers' by Francesco Marchioni, which focuses on building efficient Java applications using MongoDB. It includes links to download the full version and other related ebooks. Additionally, it features details about the author and reviewers, as well as a comprehensive table of contents for the book.

Uploaded by

soopinjusys20
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Visit ebooknice.

com to download the full version and


explore more ebooks or textbooks

(Ebook) MongoDB for Java developers design, build,


and deliver efficient Java applications using the
most advanced NoSQL database by Francesco,
Marchioni ISBN 9781785280276, 9781785286292,
1785280279, 1785286293
_____ Click the link below to download _____
https://ebooknice.com/product/mongodb-for-java-developers-
design-build-and-deliver-efficient-java-applications-using-
the-most-advanced-nosql-database-32704540

Explore and download more ebooks or textbooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James


ISBN 9781459699816, 9781743365571, 9781925268492, 1459699815,
1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans


Heikne, Sanna Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success)


by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094
(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study:
the United States, 1919-41 2nd Edition by Benjamin Harrison ISBN
9781398375147, 9781398375048, 1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

(Ebook) Refactoring in Java: Improving code design and maintainability


for Java developers by Stefano Violetta

https://ebooknice.com/product/refactoring-in-java-improving-code-
design-and-maintainability-for-java-developers-55039014

(Ebook) Java EE 7 Development with WildFly by Cmil, Michal, Matloka,


Michal, Marchioni, Francesco ISBN 9781782171980, 1782171983

https://ebooknice.com/product/java-ee-7-development-with-
wildfly-55591790

(Ebook) MongoDB Applied Design Patterns: Practical Use Cases with the
Leading NoSQL Database by Rick Copeland ISBN 9781449340049, 1449340040

https://ebooknice.com/product/mongodb-applied-design-patterns-
practical-use-cases-with-the-leading-nosql-database-55144854

(Ebook) Introducing Maven, 2nd Edition: A Build Tool for Today’s Java
Developers by Balaji Varanasi

https://ebooknice.com/product/introducing-maven-2nd-edition-a-build-
tool-for-todays-java-developers-50195460
MongoDB for Java Developers

Design, build, and deliver efficient Java applications


using the most advanced NoSQL database

Francesco Marchioni

BIRMINGHAM - MUMBAI
MongoDB for Java Developers

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: August 2015

Production reference: 1070815

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78528-027-6

www.packtpub.com
Credits

Author Project Coordinator


Francesco Marchioni Shweta Birwatkar

Reviewers Proofreader
Daniel Mühlbachler Safis Editing
Weiwei Sun
Mehdi Tazi Indexer
Tejal Soni

Commissioning Editor
Veena Pagare Production Coordinator
Aparna Bhagat

Acquisition Editors
James Jones Cover Work
Aparna Bhagat
Nadeem N. Bagban

Content Development Editor


Neeshma Ramakrishnan

Technical Editor
Bharat Patil

Copy Editors
Merilyn Pereira
Laxmi Subramanian
About the Author

Francesco Marchioni is a Red Hat Certified JBoss Administrator (RHCJA)


and a Sun Certified enterprise architect working as a freelancer in Rome, Italy.
He started learning Java in 1997, and since then, he has followed the path to the
newest application program interfaces released by Sun. In 2000, he joined the
JBoss community, when the application server was running the release 2.X.

He has spent many years as a software consultant, wherein he envisioned many


successful software migrations from vendor platforms to open source products
such as JBoss AS, fulfilling the tight budget requirements of current times.

Over the past 5 years, he has been authoring technical articles for OReilly Media and
running an IT portal focused on JBoss products (http://www.mastertheboss.com).

In December 2009, he published JBoss AS 5 Development, which describes how to


create and deploy Java Enterprise applications on JBoss AS (http://www.packtpub.
com/jboss-as-5-development/book).

In December 2010, he published his second title, JBoss AS 5 Performance Tuning,


which describes how to deliver fast and efficient applications on JBoss AS
(http://www.packtpub.com/jboss-5-performance-tuning/book).

In December 2011, he published yet another title, JBoss AS 7 Configuration, Deployment,


and Administration, which covers all the aspects of the newest application server
release (http://www.packtpub.com/jboss-as-7-configuration-deployment-
administration/book).

In June 2013, he authored a new title, JBoss AS 7 Development, which focuses on


developing Java EE 6 API applications on JBoss AS 7 (https://www.packtpub.com/
application-development/jboss-7-development).
About the Reviewers

Daniel Mühlbachler got interested in computer science shortly after entering


high school, where he later developed web applications as part of a scholarship
system for outstanding pupils.

He has profound knowledge of web development (PHP, HTML, CSS/LESS, and


AngularJS), and has worked with a variety of other programming languages and
systems, such as Java/Groovy, Grails, Objective-C and Swift, Matlab, C (with Cilk),
Node.js, and Linux servers.

Furthermore, he works with some database management systems based on SQL


and also some NoSQL systems, such as MongoDB and SOLR; this is also reflected
in several projects that he is currently involved in at Catalysts GmbH.

After studying abroad as an exchange student in the United Kingdom, he completed


his bachelor's degree at the Johannes Kepler University in Linz, Austria, with a thesis
on aerosol satellite data processing for mobile visualization; this is where he also
became familiar with processing large amounts of data.

Daniel enjoys solving challenging problems and is always keen on working with new
technologies, especially related to the fields of big data, functional programming,
optimization, and NoSQL databases.

More detailed information about his experience , as well as his contact details, can be
found at www.muehlbachler.org and www.linkedin.com/in/danielmuehlbachler.
Weiwei Sun is a student of Southeast University, China, and also a student of
Monash University, Australia. He also has a double master's degree in computer
technology and information technology. He loves technology, programming, and
open source projects.

His research interests are database technology, data visualization, and application of
machine learning.

You can read more about him at http://wwsun.github.com.

Mehdi Tazi is a software engineer specializing in distributed information systems


and agile project management.

His core expertise involves managing agile scrum teams, as well as architecting
new solutions, and working with multiple technologies, such as JAVA/JEE, Spring,
MongoDB, Cassandra, HTML5, Bootstrap, and AngularJS.

He has a degree in software engineering and a master's degree in business


informatics. He also has several certifications, such as Core-Spring, MongoDB,
Cassandra, and Scrum Master Official.

You can read more about him at http://tazimehdi.com.


www.PacktPub.com

Support files, eBooks, discount offers, and more


For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles,


sign up for a range of free newsletters and receive exclusive discounts and offers
on Packt books and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
This book is dedicated to all the guys that patiently answered my questions
on MongoDB forums and to my son Alessandro that taught me
how to play 'Magic the Gathering' while waiting for replies
Table of Contents
Preface v
Chapter 1: Introduction to MongoDB 1
Getting into the NoSQL movement 1
Comparing RDBMS and NoSQL databases 4
Living without transactions 6
Managing read-write concurrency 7
MongoDB core elements 8
The heart of MongoDB – the document 9
Understanding how MongoDB stores data 10
Data types accepted in documents 11
Installing and starting MongoDB 12
Installing MongoDB on Windows 12
Installing MongoDB on Linux 13
MongoDB start up options 14
Troubleshooting MongoDB installation 15
Mongo tools 16
Introduction to the MongoDB shell 18
Inserting documents 19
Querying documents 19
Choosing the keys to return 20
Using ranges in your queries 21
Using logical operators to query data 22
Updating documents 22
Deleting data 24
Beyond basic data types 25
Arrays 25
Embedded documents 26
Some useful functions 27
Securing database access 28
Summary 30
[i]
Table of Contents

Chapter 2: Getting Started with Java Driver for MongoDB 31


Getting the Mongo JDBC driver 31
Creating your first project 32
Creating a new Java project 32
Handling authentication 35
Inserting a document 36
Creating embedded documents 38
Inserting an array of data 38
Using your own ID in documents 40
Querying data 41
Restricting the search to the first document 43
Querying the number of documents in a collection 43
Eager fetching of data using DBCursor 43
Filtering through the records 44
Updating documents 45
Deleting documents 46
Deleting a set of documents 47
Performing operations on collections 47
Listing collections 48
Dropping a collection 49
Using the MongoDB Java driver version 3 49
Running the HelloWorld class with driver v.3 50
Managing collections 51
Inserting data into the database 51
Inserting embedded documents 52
Inserting multiple documents 53
Querying documents 53
Filtering through documents 54
Updating documents 55
Deleting documents 56
Summary 56
Chapter 3: MongoDB CRUD Beyond the Basics 57
Seeing MongoDB through the Java lens 57
Extending the MongoDB core classes 58
Using the Gson API with MongoDB 62
Downloading the Gson API 62
Using Gson to map a MongoDB document 63
Inserting Java objects as a document 65
Mapping embedded documents 66
Custom field names in your Java classes 68
Mapping complex BSON types 69
Using indexes in your applications 72
Defining an index in your Java classes 75
Using compound indexes 77

[ ii ]
Table of Contents

Using text indexes in your documents 80


Coding bulk operations 83
Comparing plain inserts with BulkWriteOperations 84
Summary 85
Chapter 4: MongoDB in the Java EE 7 Enterprise Environment 87
Entering into the Java EE land 87
Getting a Java EE Container 89
Downloading WildFly 89
Starting WildFly and testing the installation 90
Designing our application 90
Designing the schema 91
Building up the Enterprise project with NetBeans 92
Configuring WildFly on NetBeans 92
Creating our project 94
Adding Java classes 99
Compiling and deploying the project 107
Compiling and deploying from the shell 107
Running the application 108
Exposing the application to external clients 109
Adding RESTful web services to our application 109
Compiling and deploying the application 112
Summary 113
Chapter 5: Managing Data Persistence with
MongoDB and JPA 115
An overview of the Java Persistence API 115
Entering Hibernate OGM 117
Building a JPA project that uses Hibernate OGM 119
Configuring the project dependencies 121
Mapping the database collections 122
Configuring persistence 125
Coding the controller and EJB classes 126
Hibernate OGM and JP-QL 128
Coding a controller bean 129
Coding the views 131
The main view 132
The newCustomer view 133
The newOrder view 134
Compiling and running the example 135
A look into MongoDB 137
Using native queries in your Hibernate OGM 138
Summary 139

[ iii ]
Table of Contents

Chapter 6: Building Applications for MongoDB with


Spring Data 141
Introducing Spring Boot 141
Getting started with Spring Boot 142
Getting started with Spring Data 143
Using the Spring repository to access MongoDB 144
Coding our Spring Boot application 145
Serving MongoDB using Spring REST 153
Using the Mongo template component to access MongoDB 157
Building up the data access layer 157
Adding the Application class 160
Creating fine grained queries using Criteria 161
Summary 163
Index 165

[ iv ]
Preface
The NoSQL movement is growing in relevance, and it is attracting more and more
developers. The MongoDB database is a well-recognized rising star in the NoSQL
world. It is a document database that allows data to persist and query data in a
nested state without any schema constraint and complex joins between documents.
Understanding when it is appropriate to use MongoDB against a relational database
and the interfaces to be used to interact with it requires some degree of experience.

This book provides all the knowledge to make MongoDB fit into your application
schema, at the best of its capabilities. It starts from a basic introduction to the driver
that can be used to perform some low level interaction with the storage. Then it
moves on to use different patterns for abstracting the persistence layer into your
applications, starting from the flexible Google JSON library, to the Hibernate OGM
framework, and finally landing on the Spring Data framework.

What this book covers


Chapter 1, Introduction to MongoDB, covers the installation steps of MongoDB and its
client tools and how to use the Mongo shell to perform basic database operations.

Chapter 2, Getting Started with Java Driver for MongoDB, introduces the Java
Driver for MongoDB using a simple Java project developed with the NetBeans
development environment.

Chapter 3, MongoDB CRUD Beyond the Basics, covers the advanced usage of the
MongoDB Java driver such as data mapping, index creation, and bulk operations.

Chapter 4, MongoDB in the Java EE 7 Enterprise Environment, demonstrates how to


create and deploy a Java Enterprise application that uses MongoDB as the storage.

[v]
Preface

Chapter 5, Managing Data Persistence with MongoDB and JPA, covers the development
of a Java Enterprise application using Hibernate Object/Grid Mapper (OGM), which
provides Java Persistence API (JPA) support for NoSQL databases.

Chapter 6, Building Applications for MongoDB with Spring Data, teaches you how
to use Spring Data and Spring Boot to leverage micro services using MongoDB
as the storage.

What you need for this book


The following software will be needed to run the examples contained in this book:

• Java Development Kit 1.7 or newer


• Mongo DB 2.6 or newer
• MongoDB JDBC Driver 2 and 3
• The NetBeans development environment (or equivalent)

All the software mentioned is freely available for downloading.

Who this book is for


This book is for Java developers and architects who want to learn how to develop
Java applications using the most popular NoSQL solution and its use cases.

Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"In command prompt, navigate to the bin directory present into the mongodb
installation folder and point to the folder where data is stored."

A block of code is set as follows:


MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
DB db = mongoClient.getDB( "test" );
System.out.println("Successfully connected to MongoDB");

[ vi ]
Preface

When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
DB db = mongoClient.getDB( "test" );
System.out.println("Successfully connected to MongoDB");

Any command-line input or output is written as follows:


> db.users.find({}).sort({"name":1})

{ "_id" : ObjectId("5506d5708d7bd8471669e674"), "name" : "francesco",


"age" : 44, "phone" : "123-456-789" }
{ "_id" : ObjectId("550ad3ef89ef057ee0671652"), "name" : "owen", "age" :
32, "phone" : "555-444-333" }

New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes for example, appear in the text like this: " Now let's
add a Java class to the project. From the File menu, select Java Class under New ".

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to feedback@packtpub.com,


and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.

[ vii ]
Preface

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.

Downloading the example code


You can download the example code files for all Packt books you have purchased
from your account at http://www.packtpub.com. If you purchased this book
elsewhere, you can visit http://www.packtpub.com/support and register to have
the files e-mailed directly to you.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you would report this to us. By doing so, you can save
other readers from frustration and help us improve subsequent versions of this book.
If you find any errata, please report them by visiting http://www.packtpub.com/
submit-errata, selecting your book, clicking on the errata submission form link,
and entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded on our website, or added to any list
of existing errata, under the Errata section of that title. Any existing errata can be
viewed by selecting your title from http://www.packtpub.com/support.

Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected


pirated material.

We appreciate your help in protecting our authors, and our ability to bring you
valuable content.

Questions
You can contact us at questions@packtpub.com if you are having a problem with
any aspect of the book, and we will do our best to address it.
[ viii ]
Chapter 1

Introduction to MongoDB
In this book, you will learn how to develop Java applications using the MongoDB
database, which is an open source document-oriented database, recognized as a
rising star in the NoSQL world. In a nutshell, MongoDB is a document database,
which allows data to persist in a nested state, and importantly, it can query that
nested data in an ad hoc fashion. It enforces no schema, so documents can optionally
contain fields or types that no other document in the collection contains.

The focus of this book is on applications development; however, we will at first


gather all the resources to connect to MongoDB and add a quick introduction to
the world of NoSQL databases. We will cover the following topics in more detail:

• A bird's eye view of the NoSQL landscape


• Installing MongoDB and client tools
• Using the MongoDB shell

Getting into the NoSQL movement


NoSQL is a generic term used to refer to any data store that does not follow the
traditional RDBMS model—specifically, the data is nonrelational and it generally
does not use SQL as a query language. Most of the databases that are categorized
as NoSQL focus on availability and scalability in spite of atomicity or consistency.

This seems quite a generic definition of NoSQL databases; however, all databases
that fall into this category have some characteristics in common such as:

• Storing data in many formats: Almost all RDBMS databases are based on
the storage or rows in tables. NoSQL databases, on the other hand, can use
different formats such as document stores, graph databases, key-value stores
and even more.

[1]
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of Roaming
Through the West Indies
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Roaming Through the West Indies

Author: Harry Alverson Franck

Release date: November 17, 2018 [eBook #58289]

Language: English

Credits: Produced by Richard Tonsing and the Online Distributed


Proofreading Team at http://www.pgdp.net (This file
was
produced from images generously made available by
The
Internet Archive)

*** START OF THE PROJECT GUTENBERG EBOOK ROAMING


THROUGH THE WEST INDIES ***
Shade-grown tobacco in Porto Rico
ROAMING THROUGH THE WEST
INDIES

BY

HARRY A. FRANCK
Author of “A Vagabond Journey Around the World,” “Zone Policeman 88,” “Vagabonding Down the Andes,”
etc., etc.

ILLUSTRATED WITH PHOTOGRAPHS


BY THE AUTHOR

NEW YORK
THE CENTURY CO.
1920
Copyright, 1920, by
The Century Co.

TO
MY WIFE, RACHEL,
WITH WHOM THIS WAS THE BEGINNING
OF A FAR LONGER JOURNEY, AND
TO
MY SON, HARRY,
WHO JOINED US ON THE WAY
FOREWARNING

Some years ago I made a tramping trip around the world for my
own pleasure. Friends coaxed me to set it down on paper and new
friends were kind enough to read it. Since then they have demanded
more—at least so the publishers say—but always specifying that it
shall be on foot. Now, I refuse to be dictated to as to how I shall
travel; I will not be bullied into tramping when I wish to ride. The
journey herewith set forth is, therefore, among other things, a
physical protest against that attempted coercion, a proof that I do
not need to walk unless I choose to do so. To make broken
resolutions impossible, I picked out a trip that could not be done on
foot. It would be difficult indeed to walk through the West Indies.
Then, to make doubly sure, I took with me a newly acquired wife—
and we brought back a newly acquired son, though that has nothing
to do with the present story.
I will not go so far as to say that I abjured footing it entirely. As a
further proof of personal liberty I walked when and where the spirit
moved me—and the element underfoot was willing. But I wish it
distinctly understood from the outset that this is no “walking trip.”
Once having broken the friends who flatter me with their attention of
expecting me to confine myself to the prehistoric form of locomotion
—I shall probably take to the road again to relieve a chronic foot-itch.
The following pages do not pretend to “cover” the West Indies.
They are made up of the random pickings of an eight-months’ tour of
the Antilles, during which every island of importance was visited, but
they are put together rather for the entertainment of the armchair
traveler than for the information of the traveler in the flesh. While
the latter may find in them some points to jot down in his itinerary,
he should depend rather on the several thorough and orderly books
that have been written for his special benefit.
Harry A. Franck.
TABLE OF CONTENTS

CHAPTER PAGE

I Overland to the West Indies 3

THE AMERICAN WEST INDIES

II Random Sketches of Havana 25

III Cuba from West to East 50

IV The World’s Sugar-Bowl 76

V Under the Palm-Tree of Haiti 106

VI The Death of Charlemagne 128

VII Hither and Yon in the Haitian Bush 149

VIII The Land of Bullet-Holes 189

IX Travels in the Cibao 207

X Santo Domingo Under American Rule 229

XI Our Porto Rico 256

XII Wandering About Borinquen 280


XIII In and About Our Virgin Islands 304

THE BRITISH WEST INDIES

XIV The Caribbee Islands 339

XV “Little England” 360

XVI Trinidad, the Land of Asphalt 381

XVII African Jamaica 403

THE FRENCH WEST INDIES AND THE OTHERS

XVIII Guadeloupe and Dependencies 439

XIX Rambles in Martinique 449

XX Odds and Ends in the Caribbean 475


LIST OF ILLUSTRATIONS

Shade-grown tobacco in Porto Rico Frontispiece

FACING
PAGE

St. Augustine, Florida, from the old Spanish fortress 16

A policeman of Havana 16

Cuba’s new presidential palace 17

Venders of lottery tickets in rural Cuba 32

The winning numbers of the lottery 32

Pigeons are kept to clear the tobacco fields of insects 33

Ploughing for tobacco in the famous Vuelta Abajo district.


The large building is a tobacco barn, the small ones are
residences of the planters 33

A Cuban shoemaker 56

Cuban soldiers 56

Matanzas, with drying sisal fiber in the foreground 57

The Central Plaza of Cienfuegos 57


A principal street of Santa Clara 64

The Central Plaza of Santa Clara 64

A dairyman, Santa Clara district 65

Cuban town scenery 65

A Cuban residence in a new clearing 114

Planting sugar-cane on newly cleared land 114

Hauling cane to a Cuban sugar-mill 115

A station of a Cuban pack train 115

Cuban travelers 80

A Cuban milkman 80

A street of Santiago de Cuba 81

Not all Chinamen succeed in Cuba 81

The entire enlisted personnel of the Haitian Navy 112

A school in Port au Prince 112

The central square and Cathedral of Port au Prince on


market day 113

Looking down upon the market from the cathedral platform 113

A Haitian gendarme 128

The president of Haiti 128


A street in Port au Prince 129

The unfinished presidential palace of Haiti, on New Year’s


Day, 1920 129

A Haitian country home 144

A small portion of one collection of captured caco war


material 144

The caco in the foreground killed an American Marine 145

Captain Hanneken and “General Jean” Conzé at


Christophe’s Citadel 145

Ruins of the old French estates are to be found all over Haiti 160

A Haitian wayside store 160

The market women of Haiti sell everything under the sun—


A “General” in a Haitian market 161

There are still more primitive sugar-mills than these in


Haiti 161

A corner of Christophe’s Citadel. Its situation is such that it


could only be well photographed from an airplane 176

The ruins of Christophe’s palace of San Souci 176

The mayor, the judge, and the richest man of a Haitian town
in the bush 177

Cockfighting is a favorite Haitian sport 177

The plaza and clock tower of Monte Cristo, showing its


American bullet hole 192

Railroading in Santo Domingo 192


The tri-weekly train arrives at Santiago 193

Dominican guardias 193

Gen. Deciderio Arias, now a cigar maker, whose revolution


finally caused American intervention in Santo Domingo 208

A bread seller of Santo Domingo 208

The church within a church of Moca 209

The “holy place” of Santo Domingo on top of the Santo


Cerro where Columbus planted a cross 209

A Dominican switch engine 224

A Dominican hearse 224

American Marines on the march 225

A riding horse of Samaná 225

Advertising a typical Dominican theatrical performance 240

A tree to which Columbus tied one of his ships, now on the


wharf of Santo Domingo City 240

The tomb of Columbus in the cathedral of Santo Domingo


City 241

Ponce de Leon’s palace now flies the Stars and Stripes 256

Thousands of women work in the fields in Porto Rico 256

Air-plants grow even on the telegraph wires in Ponce 257

A hat seller of Cabo Rojo 257


There is school accommodation for only half the children of
our Porto Rico 272

The home of a lace-maker in Aguadilla 273

The Porto Rican method of making lace 273

The place of pilgrimage for pious Porto Ricans 288

Porto Rican children of the coast lands 288

The old sugar-kettles scattered through the West Indies


have many uses 289

A corner in Aguadilla 289

The priest in charge of Porto Rico’s place of pilgrimage 296

One reason why cane-cutters cannot all be paid the same


wages 296

A procession of strikers in honor of representatives of the A.


F. of L. 297

“How many of you are on strike?” asked Senator Iglesias 297

The new church of Guayama, Porto Rico 304

A Porto Rican ex-soldier working as road peon. He gathers


the grass with a wooden hook and cuts it with a small
sickle 304

Porto Rican tobacco fields 305

Charlotte Amalie, capital of our Virgin Islands 305

A corner of Charlotte Amalie 320


Picking sea-island cotton, the second of St. Croix products 320

A familiar sight in St. Croix, the ruins of an old sugar mill


and the stone tower of its cane-grinding windmill 321

A cistern in which rain water is stored for drinking purposes 321

Roseau, capital of beautiful Dominica 352

A woman of Dominica bringing a load of limes down from


the mountain 352

Kingstown, capital of St. Vincent 353

Trafalgar Square, Bridgetown, Barbados, with its statue of


Nelson 353

The Prince of Wales lands in Barbados 368

The principal street of Bridgetown, decorated in honor of its


royal visitor 368

Barbadian porters loading hogsheads of sugar always take


turns riding back to the warehouse 369

There is an Anglican Church of this style in each of the


eleven parishes of Barbados 369

The turn-out of most Barbadians 384

A Barbadian windmill 385

Two Hindus of Trinidad 385

Trinidad has many Hindu temples 400

Very much of a lodge 400


At the “Asphalt Lake” 401

There is water, too, in the crevices of the asphalt field 401

As I passed this group on a Jamaican highway, the woman


reading the Bible was saying “So I ax de Lard what I shall
do” 416

“Draw me portrait please, sir!” The load consists of school


books and a pair of hobnail shoes 416

A very frequent sight along the roads of Jamaica 417

Our baggage following us ashore in one of the French


islands 417

Private graveyards are to be found all over Jamaica 432

A street of Basse Terre, capital of Guadeloupe 432

A woman of Guadeloupe 433

The town criers of Pointe à Pitre 433

In the outskirts of Guadeloupe’s commercial capital 448

Fort de France, capital of Martinique 448

The savane of Fort de France, with the Statue of Josephine,


once Empress of the French 449

Women of Martinique 464

A principal street of Fort de France with its cathedral 464

The shops of Martinique are sometimes as gaily garbed as


the women 465
Empress Josephine was born where this house stands 465

The St. Pierre of to-day with Pélée in the background 472

The cathedral of St. Pierre 473

The present residents of St. Pierre tuck their houses into the
corners of old stone ruins 473

The harbor of Curaçao 480

A woman of Curaçao 480

The principal Dutch island is not noted for its verdure 481

A Curaçao landscape 481

MAP

The itinerary of the author 48


ROAMING THROUGH THE WEST INDIES
CHAPTER I
OVERLAND TO THE WEST INDIES

W e concluded that if we were to spend half a year or more


rambling through the West Indies we would get sea-water
enough without taking to the ships before it was necessary. Our first
dream was to wander southward in the sturdy, if middle-aged,
gasolene wagon we must otherwise leave behind, abandoning it for
what it would bring when the mountains of central Cuba grew too
difficult for its waning vigor. But the tales men told of southern
highways dampened our ardor for that particular species of
adventure. They were probably exaggerated tales. Looking back upon
the route from the eminence of automobile-infested Havana, we are
of the impression that such a trip would have been marred only by
some rather serious jolting in certain parts of the Carolinas and
southern Georgia, and a moderately expensive freight-bill from the
point where lower Florida turns to swamps and islands. If our people
of the South carry out the ambitious highway plans that are now
being widely agitated, there is no reason that the West Indian
traveler of a year or two hence should hesitate to set forth in his own
car.
The rail-routes from the northeastern states are three in number,
converging into one at something over five hundred miles from the
end of train travel. Those to whom haste is necessary or more
agreeable than leisure may cover the distance from our greatest to
our southernmost city in forty-eight hours, and be set down in
Havana the following dawn. But with a few days to spare the broken
journey is well worth the enhanced price and trouble. A truer
perspective is gained by following the gradual change that increasing
length of summer gives the human race rather than by springing at
once from the turmoil of New York to the regions where winter is
only a rumor and a hearsay.
In the early days of October the land journey southward is like the
running backward of a film depicting nature’s processes. The rich
autumn colors and the light overcoats of Pennsylvania advance
gradually to the browning foliage and the wrap-less comfort of the
first autumn breezes, then within a few hours to the verdant green
and simpler garb of full summer. There are reservations, however, in
the change of human dress, which does not keep pace with that of the
landscape. Our Southerners seem to be ruled in sartorial matters
rather by the dictators of New York fashions than by the more fitting
criterion of nature, and the glistening new felt fedora persists far
beyond the point where the lighter covering would seem more
suitable to time and place.
To the Northerner the first item of interest is apt to be the sudden
segregation of races in the trains leaving Washington for the South.
From the moment he surreptitiously sheds his vest as he rumbles
across the Potomac the traveler finds his intercourse with his African
fellow-citizens, be they jet black or pale yellow, circumscribed by an
impregnable wall that is to persist until all but a narrow strip of his
native land has shrunk away behind him. Only as superior to
inferior, as master to servant, or as a curiosity akin to that of the
supercilious voyager toward the “natives” of some foreign land, is his
contact henceforth with the other race. Stern placards point out the
division that must be maintained in public buildings or conveyances;
custom serves as effectually in private establishments; the very city
directories fetch up their rear with the “Colored Department.”
The tourist’s first impression of Richmond will largely depend on
whether his train sets him down at the disreputable Main Street
station or at the splendid new Union Depot on the heights of Broad
Street. Unfortunately, the latter is as yet no more nearly “union” than
it is, in spite of a persistent American misnomer, a “depot,” and his
chances of escaping the medieval landing-place are barely more than
“fifty-fifty.” But his second notion of the erstwhile capital of the
Confederacy cannot but be favorable, unless his tastes run more to
the picturesque than to modern American civilization. He may at this
particular season grumble at a sweltering tropical heat that appears
long before he bargained for it, but the hospitable Richmonder
quickly appeases his wrath in this regard by explaining that some
malignant cause, ranging from the disturbance of the earth’s orbit by
the war just ended to a boiling Gulf Stream, has given the South the
hottest autumn in—I hesitate to say how many decades. Nor, if he is
new to the life below Mason and Dixon’s Line, will he escape a
certain surprise at finding how green is still the memory of the
Confederacy. The Southerner may have forgiven, but he has not
forgotten, nor does he intend that his grandchildren shall do so.
In that endless stretch of sand, cotton, and pine-trees which is
locally known as “Nawth Cahlina, sah,” there are other ways of
passing the time than by watching the endless unrolling of a
sometimes monotonous landscape. One can get into conversation,
for instance, with the train-crew far more easily than in the more
frigid North, and listen for hours to more or less verdant anecdotes,
which the inimitable Southern dialect alone makes worth the
hearing. Or, if wise enough to abandon the characterless
cosmopolitan Pullman for the local atmosphere of the day coach, one
may catch such scraps as these—of special interest to big-game
hunters—from the lips of fellow-passengers:
“Say, d’ you hear about Bud Hampton?”
“What Bud done now?”
“Why, las’ week Bud Hampton shot a buck niggah’t weighed ovah
two hunderd pound!”
This particular species of quarry seemed to grow blacker with each
succeeding state. The two urchins in one-piece garments who lugged
our hand-bags up the slope in Columbia made coal seem of a pale
tint by comparison. At the corner of a main street so business-bent as
to require the constant attention of a traffic policeman they steered
us toward the door of a somewhat weather-worn establishment.
“This the best hotel?” I queried, a bit suspicious that the weight of
their burdens had warped their judgment. “How about that one
down the street?” It was a building of very modern aspect, looming
ten full stories into the brilliant Southern heavens.
“Dat ain’ no hotel, sah,” cried the two in one breath, rolling their
snow-white eyeballs, their black toes seeming to wriggle with pride at
the magnificence it presented, “dat’s de sky-scrapah!”
It was in Columbia that we felt for the first time irrevocably in the
South. Richmond had been merely an American city with a Southern
atmosphere; South Carolina’s capital was the South itself, despite its
considerable veneer of modern Americanism. One must look at three
faces to find one indubitably white. Clusters of mahogany-red sugar-
canes lolled in shady corners, enticing the black brethren to exercise
their powerful white teeth. Goats drowsed in patches of sand
protected from the insistent sunshine. Motormen raised their caps
with one hand and brought their dashing conveyances to a sudden
halt with the other at the very feet of their “lady acquaintances,”
whose male escorts returned the greeting with equal solemnity. I
puzzled for some time to know what far-distant city this one, with its
red soil stretching away to suburban nothingness from the points
where the street paving petered out, with its goats and sugar-cane, its
variegated complexions, and frank contentment with life, was
insistently recalling to memory. Then all at once it came to me.
Purged of its considerable American bustle, Columbia would bear a
striking resemblance to Asunción, capital of far-off Paraguay. Even
the wide-open airiness of its legislative halls, drowsing in the
excusable inoccupancy of what was still mid-summer despite the
calendar, carried the imagination back to the land of the Guaraní.
An un-Northern spaciousness was characteristic of the chief
hostelry, with its ample chambers, its broad lounging-room, its
generously gaping spitoons, offering not too exacting a target to the
inattentive fire of Southern marksmanship. The easy-going
temperament of its management came as a relief from the
unflinching rule-of-thumb back over the horizon behind us. The
reign of the old-fashioned “American plan,” synonymous with eating
when and what the kitchen dictates rather than leaving the guest a
few shreds of initiative, had begun again and was to persist for a
thousand miles southward. But can some trustworthy authority tell
us what enactment requires that the “choicest room” of the “best
hotel” of every American city be placed at the exact junction-point of
the most successful attempt to concentrate all its twenty-four hours
of uproar? I ask not in wrath, for time and better slumber have
assuaged that, but out of mere academic curiosity. In the good, old
irresponsible days of my “hobo” youth the “jungle” beyond the
railroad yards was far preferable to this aristocratic Bedlam.

The “sky-scrapah” loomed behind us for half an hour or more


across the mighty expanse of rolling sand-and-pine-tree world, with
its distance-purple tinge and its suggestion of the interior of Brazil,
which fled northward on the next lap of our journey. The cotton-
fields which interspersed the wilderness might have seemed patches
of daisies to the casual glance, rather sparse and thirsty daisies, for
this year the great Southern crop had sadly disappointed its
sponsors. Powder-dry country roads of reddish sand straggled along
through the endless stretches of scrub-pines, carrying here and there
the sagging buggy and gaunt and dust-streaked horse of former days.
I relegate the equine means of transportation to the past advisedly,
for his doom was apparent even in these sparsely cultivated and
thinly peopled regions. Before a little unpainted, wooden negro
church that drifted by us there clustered twenty-eight automobiles,
with a bare half-dozen steeds drooping limply on their weary legs in
the patches of shade the machines afforded them. King Cotton,
abetted by his royal contemporaries overseas, has drawn no color-
line in deluging his favors on his faithful subjects. Forests of more
genuine trees replaced the scrub growth for long spaces farther on;
here and there compact rectangles of superlatively green sugar-cane
contrasted with the dead-brown patches of shriveled corn. In the
smoking compartment of the coach placarded “White” shirt-sleeves
and open collars were the rule, but the corresponding section of the
“Colored” car indulged in no such disheveled comfort. The negroes of
the South seem more consistent followers of Beau Brummel than
their white neighbors.
We descended at Savannah in a hopeful frame of mind, for a
recent report announced it the most nearly reasonable in its food
prices of the fifty principal cities of our United States. Georgia’s
advantage in the contest with starvation was soon apparent. At the
desk of the hotel overlooking a semi-tropical plaza the startled
newcomer found staring him in the face a dire threat of
incarceration, in company with the recipient, if he so far forgot
himself as to offer a gratuity. There was something strangely
familiar, however, about the manner of the grandson of Africa who
hovered about the room to which he had conducted us, flecking away
a speck of dust here, raising a curtain and lowering it again to the
self-same height over yonder. I had no desire to spend even a short
span of my existence in a Southern dungeon, along with this dusky
bearer of the white man’s burdens. But he would have made a most
unsuitable spectator to the imperative task of removing the Georgian
grime of travel. Enticing him into a corner out of sight of the key-
hole I called his attention to the brilliancy of a silver coin. Instead of
springing to a window to shout for the police, he snatched the
curiosity in a strangely orthodox manner, flashed upon us a row of
dazzlingly white teeth, and wished us a pleasant evening. Possibly I
had read the anti-tipping ordinance too hastily; it may merely have
forbidden the public bestowal of gratuities.
A microscopic examination might possibly have proved that the
reckoning which was laid before us at the end of dinner showed some
signs of shrinkage; to the naked eye it was quite as robust as its twin
brothers to the North. But of course the impossibility of leaving a
goodly proportion of the change to be cleared away with the crumbs
would account for Savannah’s low cost of living. The lengthening of
the ebony face at my elbow as I scraped the remnants of my bank-
note together might have been due to the exertions of the patent-
leather shoes that sustained it to contain more than their fair share
of contents. But it seemed best to make sure of the source of dismay;
we might have to eat again before we left Savannah.
“I understand you can’t accept tips down here in Georgia?” I
hazarded, reversing the usual process between money and pocket.
The increasing elongation of the waiter’s expression branded the
notion a calumny even sooner than did his anxious reply:
“Ah been taking ’em right along, sah. Yes, sah, thank you, sah. Dey
did try to stop us makin’ a livin’, sah, but none of de gen’lemans do’n
ferget us.”
I can highly commend the anti-tipping law of Georgia; it gives one
a doubled sense of adventure, of American freedom from restraint,
reminiscent of the super-sweetness of stolen apples in our boyhood
days.
We liked Savannah; preferred it, perhaps, to any of the cities of our
journey southward. We liked the Southern hospitality of its churches,
consistent with their roominess and their wide-open windows. We
were particularly taken with the custom of furnishing fans as well as
hymn-books, though we may have wondered a bit whether the
segregation of the colored people persisted clear beyond St. Peter’s
gate. We were especially grateful to the genius of Oglethorpe, who
had made this a city of un-American spaciousness, with every other
cross street an ample boulevard, which gave the lungs and the eyes a
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!

ebooknice.com

You might also like