Grammars define the dialect of conversion for field types, because sql is not even standard on all database,
for example sql dialect of oracle have some differences from mysql dialect. csv2sql support some of most
common dialect, and can also be extended.
To add a new dialect support you must extend net.sf.csv2sql.grammars.AbstractGrammarFactory,
this class is a factory that creates net.sf.csv2sql.grammars.AbstractField from a string.
This is the AbstractGrammarFactory class:
public abstract class AbstractGrammarFactory {
public abstract AbstractField createField(String type, String name, Properties prop)
throws GrammarFactoryException;
}
Wich Properties prop parameter extra information can be used by the field (like date format, precision, ...).
String name parameter define the name of the field in the database.
You simply need to override the createField() method, and instantiate a new
net.sf.csv2sql.grammars.AbstractField based on String type parameter.
|