Registering the Connector Class
Before connecting to your data, you must register the appropriate class for your application.
The following classes are used to connect the Simba MongoDB JDBC Driver to
- The
Driverclasses extendjava.sql.Driver. - The
DataSourceclasses extendjavax.sql.DataSourceandjavax.sql.ConnectionPoolDataSource.
The connector supports the following fully-qualified class names (FQCNs) that are independent of the JDBC version:
The following sample code shows how to use the DriverManager class to establish a connection for JDBC
private static Connection connectViaDM() throws Exception
{
Connection connection = null;
connection = DriverManager.getConnection(CONNECTION_URL);
return connection;
}
The following sample code shows how to use the DataSource class to establish a connection:
private static Connection connectViaDS() throws Exception
{
Connection connection = null;
DataSource ds = new com.simba.mongodb.jdbc.DataSource();
ds.setURL(CONNECTION_URL);
connection = ds.getConnection();
return connection;
}
- Installing and Using the Simba MongoDB JDBC Driver
- System Requirements
- Referencing the JDBC Connector Libraries
- Building the Connection URL
- Configuring the Simba MongoDB JDBC Driver on page 1