Open topic with navigation

TIBCO ActiveSpaces® - Enterprise Edition 5.0.0

# Creating the ActiveSpaces JDBC Connection

After registering the ActiveSpaces JDBC driver, the next step is to make the ActiveSpaces JDBC connection.

The DriverManager interface supports the following methods for creating a connection:

    Connection getConnection(String url);
    Connection getConnection(String url, Properties info);
    Connection getConnection(String url, String user, String password);

The `url` parameter is the JDBC URL to connect to a database, or in our case a data grid. Ensure that `url` adheres to the format specified in JDBC URL Format. The `info` parameter is optional and can contain a set of Java properties that are required for connecting to the data grid. To understand these properties, see ActiveSpaces Properties .
Note: Properties passed to the connect() method override the properties specified in the JDBC URL. The names of the properties follow the same rules for property names in the JDBC URL.
Before you beginFirst complete the steps listed in Registering the ActiveSpaces JDBC Driver with the Driver Manager.

Procedure After registering the driver, create a JDBC connection to the data grid. To connect to the data grid, you can use any of the getConnection() methods. The following code snippet uses Connection getConnection(String url) :

        // create a JDBC connection to the data grid
                String jdbcURL = "jdbc:tibco:tibdg:_default;realmurl=
                http://localhost:8080";
                java.sql.Connection jdbcConnection =
                java.sql.DriverManager.getConnection(jdbcURL);

## An Example of Registering and Connecting to the Data Grid

This example shows the code snippet to be inserted to your Java code to register and connect to the data grid. The following example uses the Connection getConnection(String url, Properties info) method to create a connection.

    public java.sql.Connection getConnection (Properties props) throws SQLException
            {
                // Register the ActiveSpaces JDBC Driver with the JDBC
                 DriverManager
                try
                {
                    Class.forName("com.tibco.datagrid.jdbc.DriverImpl");
                }
                catch (ClassNotFoundException ex)
                {
                    // handle exception
                }

                // Establish a JDBC connection to the data grid
                String jdbcURL = "jdbc:tibco:tibdg:_default";
                Properties props = new Properties();
                props.setProperty(
                com.tibco.datagrid.Connection.TIBDG_CONNECTION_PROPERTY_STRING_REALMURL,
                "http://localhost:8080");

                return java.sql.DriverManager.getConnection(jdbcURL, props)
            }

Subtopics

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO ActiveSpaces® - Enterprise Edition

Copyright © 2009-2025. Cloud Software Group, Inc. All Rights Reserved.