VOOZH about

URL: https://www.cdata.com/kb/tech/xml-jdbc-intellij.rst

⇱ How to connect to XML Data from IntelliJ


How to connect to XML Data from IntelliJ

👁 Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Integrate connectivity to XML data with wizards in IntelliJ.

The CData JDBC Driver for XML enables you to access XML as a JDBC data source, providing integration with rapid development tools in IDEs. This article shows how to use the data source configuration wizard to connect to XML data in IntelliJ.

Create a JBDC Data Source for XML

Follow the steps below to add the driver JAR and define connection properties required to connect to XML data.

  1. In the Data Sources window, right-click and then click Add Data Source -> DB Data Source.
  2. In the Data Source Properties dialog that appears, the following properties are required:

    • JDBC Driver Files: Click the button next to this menu to add the JDBC Driver file cdata.jdbc.xml.jar, located in the installation directory.
    • JDBC Driver Class: In this menu, select cdata.jdbc.xml.XMLDriver from the list.
    • Database URL: Enter the connection URL in the JDBC URL property. The URL must start with jdbc:xml: and includes connection properties separated with semicolons.

      Connecting to Local or Cloud-Stored (Box, Google Drive, Amazon S3, SharePoint) XML Files

      CData Drivers let you work with XML files stored locally and stored in cloud storage services like Box, Amazon S3, Google Drive, or SharePoint, right where they are.

      Setting connection properties for local files

      Set the URI property to local folder path.

      Setting connection properties for files stored in Amazon S3

      To connect to XML file(s) within Amazon S3, set the URI property to the URI of the Bucket and Folder where the intended XML files exist. In addition, at least set these properties:

      • AWSAccessKey: AWS Access Key (username)
      • AWSSecretKey: AWS Secret Key

      Setting connection properties for files stored in Box

      To connect to XML file(s) within Box, set the URI property to the URI of the folder that includes the intended XML file(s). Use the OAuth authentication method to connect to Box.

      Dropbox

      To connect to XML file(s) within Dropbox, set the URI proprerty to the URI of the folder that includes the intended XML file(s). Use the OAuth authentication method to connect to Dropbox. Either User Account or Service Account can be used to authenticate.

      SharePoint Online (SOAP)

      To connect to XML file(s) within SharePoint with SOAP Schema, set the URI proprerty to the URI of the document library that includes the intended XML file. Set User, Password, and StorageBaseURL.

      SharePoint Online REST

      To connect to XML file(s) within SharePoint with REST Schema, set the URI proprerty to the URI of the document library that includes the intended XML file. StorageBaseURL is optional. If not set, the driver will use the root drive. OAuth is used to authenticate.

      Google Drive

      To connect to XML file(s) within Google Drive, set the URI property to the URI of the folder that includes the intended XML file(s). Use the OAuth authentication method to connect and set InitiateOAuth to GETANDREFRESH.

      The property is the controlling property over how your data is represented into tables and toggles the following basic configurations.

      • Document (default): Model a top-level, document view of your XML data. The data provider returns nested elements as aggregates of data.
      • FlattenedDocuments: Implicitly join nested documents and their parents into a single table.
      • Relational: Return individual, related tables from hierarchical data. The tables contain a primary key and a foreign key that links to the parent document.

      See the Modeling XML Data chapter for more information on configuring the relational representation. You will also find the sample data used in the following examples. The data includes entries for people, the cars they own, and various maintenance services performed on those cars.

      Built-in Connection String Designer

      For assistance in constructing the JDBC URL, use the connection string designer built into the XML JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

      java -jar cdata.jdbc.xml.jar
      

      Fill in the connection properties and copy the connection string to the clipboard.

      👁 Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)

      A typical JDBC URL is the following:

      jdbc:xml:URI=C:/people.xml;DataModel=Relational;
👁 The JDBC data source. (Salesforce is shown.)

Edit and Save XML Data

To discover schema information, right-click the data source you just created and click Refresh Tables. To query a table, right-click it and then click Open Tables Editor. You can also modify records in the Table Editor.

👁 The results of a query in IntelliJ. (Salesforce is shown.)

Ready to get started?

Download a free trial of the XML Driver to get started:

 Download Now

Learn more:

👁 XML Documents Icon
XML JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with XML data stores.