8.5. Connecting to the Repository

In this section, we will describe how to connect to the XML repository.

8.5.1. The xmlrepDB Class

First we will create a class (xmlrepDB.java) that will handle the connection to the database and provide methods to execute SQL commands, handle long strings that need splitting into leaves, and handle any exceptions that may arise (see Listing 8.19).

Listing 8.19. xmlrepDB Class
 // Import core Java classes import java.lang.*; import java.sql.*; // The xmlrepDB class public class xmlrepDB { // Login ID and password private String username = "xmlrep_user"; private String password = "fishcakes"; // Other variables private Connection con; public Statement stmt; public int leafSize; public int elementNameLength; public ...

Get XML Data Management: Native XML and XML-Enabled Database Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.