public interface DialectFactory
Dialect
objects.
If you create a class that implements Dialect
, you may optionally
provide a factory by creating a constant field in that class. For
example:
public class MyDialect implements Dialect { public static final DialectFactory FACTORY = new JdbcDialectFactory(MyDialect.class, null); public MyDialect(Connection connection) { ... } ... }
(The field must be public, static, final, named "FACTORY", of type
DialectFactory
or a subclass, and its value must not be
null.)
Explicitly providing a factory gives you more control about how dialects are produced.
If you do not provide such a field, Mondrian requires that the dialect has
a public constructor that takes a Connection
as a parameter,
and automatically creates a factory that calls the class's public
constructor.
However, an explicit DialectFactory is superior:
null
, whereas a dialect's constructor can only throw an
exception.
If your dialect is a subclass of JdbcDialectImpl
you may wish to use a dialect factory that is a subclass of
JdbcDialectFactory
.
Modifier and Type | Method and Description |
---|---|
Dialect |
createDialect(DataSource dataSource,
Connection connection)
Creates a Dialect.
|
Dialect createDialect(DataSource dataSource, Connection connection)
If the dialect cannot handle this connection, returns null.
dataSource
- JDBC data sourceconnection
- JDBC connectionRuntimeException
- if underlying systems give an errorCopyright © 2020 Hitachi Vantara. All rights reserved.