Package org.h2gis.functions.factory

# Class H2GISDBFactory

java.lang.Object
org.h2gis.functions.factory.H2GISDBFactory

public class H2GISDBFactory extends Object
Used to create quickly a database on unit tests.

Author:
  Nicolas Fortin, Erwan Bocher

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`H2_PARAMETERS`

## Method Summary

Modifier and Type
Method
Description
`static DataSource`
`createDataSource(String dbName, boolean initSpatial)`
Create a database and return a DataSource
`static DataSource`
`createDataSource(String dbName, boolean initSpatial, String h2Parameters)`
Create a database and return a DataSource
`static DataSource`
`createDataSource(Properties properties)`
Create a database, init spatial funcyion and return a DataSource
`static DataSource`
`createDataSource(Properties properties, boolean initSpatial)`
Create a database and return a DataSource
`static Connection`
`createSpatialDataBase(String dbName)`
Create a spatial database
`static Connection`
`createSpatialDataBase(String dbName, boolean initSpatial)`
Create a spatial database and register all H2GIS functions
`static Connection`
`createSpatialDataBase(String dbName, boolean initSpatial, String h2Parameters)`
Create a spatial database
`static Connection`
`openSpatialDataBase(String dbName)`
Open the connection to an existing database

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### H2_PARAMETERS

public static final String H2_PARAMETERS

See Also:
  - Constant Field Values

## Method Details

### openSpatialDataBase

public static Connection openSpatialDataBase(String dbName) throws SQLException, ClassNotFoundException
Open the connection to an existing database

Parameters:
  `dbName` -
Returns:
Throws:
  `SQLException`
  `ClassNotFoundException`

### createSpatialDataBase

public static Connection createSpatialDataBase(String dbName) throws SQLException, ClassNotFoundException
Create a spatial database

Parameters:
  `dbName` - filename
Returns:
  Connection
Throws:
  `SQLException`
  `ClassNotFoundException`

### createDataSource

public static DataSource createDataSource(String dbName, boolean initSpatial) throws SQLException
Create a database and return a DataSource

Parameters:
  `dbName` - DataBase name, or path URI
  `initSpatial` - True to enable basic spatial capabilities
Returns:
  DataSource
Throws:
  `SQLException`

### createDataSource

public static DataSource createDataSource(Properties properties) throws SQLException
Create a database, init spatial funcyion and return a DataSource

Parameters:
  `properties` - for the opening of the DataBase.
Returns:
  a DataSource
Throws:
  `SQLException`

### createDataSource

public static DataSource createDataSource(Properties properties, boolean initSpatial) throws SQLException
Create a database and return a DataSource

Parameters:
  `properties` - for the opening of the DataBase.
  `initSpatial` - true to load the spatial functions
Returns:
  a DataSource
Throws:
  `SQLException`

### createDataSource

public static DataSource createDataSource(String dbName, boolean initSpatial, String h2Parameters) throws SQLException
Create a database and return a DataSource

Parameters:
  `dbName` -
  `initSpatial` -
  `h2Parameters` -
Returns:
Throws:
  `SQLException`

### createSpatialDataBase

public static Connection createSpatialDataBase(String dbName, boolean initSpatial, String h2Parameters) throws SQLException, ClassNotFoundException
Create a spatial database

Parameters:
  `dbName` - filename
  `initSpatial` - If true add spatial features to the database
  `h2Parameters` - Additional h2 parameters
Returns:
  Connection
Throws:
  `SQLException`
  `ClassNotFoundException`

### createSpatialDataBase

public static Connection createSpatialDataBase(String dbName, boolean initSpatial) throws SQLException, ClassNotFoundException
Create a spatial database and register all H2GIS functions

Parameters:
  `dbName` - filename
  `initSpatial` - If true add spatial features to the database
Returns:
  Connection
Throws:
  `SQLException`
  `ClassNotFoundException`