org.objectweb.jorm.mapper.rdb.adapter

Class MysqlAdapter

Implemented Interfaces:
PreparedStatementAdapter, RdbAdapter, ResultsetAdapter, SequenceAdapter, TypeAdapter, ValueAsSQLStringAdapter

public class MysqlAdapter
extends BasicRdbAdapter

MySql 4.0.12

Author:
S.Chassande-Barrioz

Field Summary

private static String
MYSQLINDEXEDLOCATE
int
varbinarySize
int
varbinarySizeInPk
private int
varcharSize
private int
varcharSizeInPk

Fields inherited from class org.objectweb.jorm.mapper.rdb.adapter.BasicRdbAdapter

CONCAT, INDEXEDLOCATE, accountForNanos, name

Fields inherited from interface org.objectweb.jorm.mapper.rdb.adapter.api.RdbAdapter

NOSIZE

Fields inherited from interface org.objectweb.jorm.mapper.rdb.adapter.api.TypeAdapter

TYPECODE_BIGDECIMAL, TYPECODE_BIGINTEGER, TYPECODE_BOOLEAN, TYPECODE_BYTE, TYPECODE_BYTEARRAY, TYPECODE_CHAR, TYPECODE_CHARARRAY, TYPECODE_DATE, TYPECODE_DOUBLE, TYPECODE_FLOAT, TYPECODE_INT, TYPECODE_LONG, TYPECODE_OBJBOOLEAN, TYPECODE_OBJBYTE, TYPECODE_OBJCHAR, TYPECODE_OBJDOUBLE, TYPECODE_OBJFLOAT, TYPECODE_OBJINT, TYPECODE_OBJLONG, TYPECODE_OBJSHORT, TYPECODE_SERIALIZED, TYPECODE_SHORT, TYPECODE_STRING, TYPE_NAMES

Constructor Summary

MysqlAdapter()

Method Summary

int
fetchResultSetSize(ResultSet rs)
This calculates the size of a result set.
char
getChar(ResultSet rs, int idx, char nullValue)
Get a char value from a ResultSet.
String
getCreateSequence(String seqName)
String
getCreateSequence(String seqName, Integer startid, Integer inc, Integer cache)
Date
getDate(ResultSet rs, int idx, String sqlColumnType, Date nullValue)
Get a Date value from a ResultSet.
String
getIndexedLocateExpression(String instring, String substring, String fromIndex)
Character
getOchar(ResultSet rs, int idx, Character nullValue)
Get a Character value from a ResultSet.
String
getSqlType(int typeCode, boolean usedInPK, int size, int scale)
This method returns the SQL type linked to the java type
int
getSqlTypeCode(int typeCode, String sqlColumnType)
This method returns the SQL type code linked to the java type specified in parameter.
protected void
modifyWhereClauseWithRange(StringBuffer sb, String _where, int rangeStart, int rangeSize)
void
setDate(PreparedStatement ps, int idx, Date o, String columnType)
Assignes a value into a PreparedStatement
void
setVarcharSize(int s)
void
setVarcharSizeInPk(int s)
boolean
supportBatchPreparedStatement()

Methods inherited from class org.objectweb.jorm.mapper.rdb.adapter.BasicRdbAdapter

escapeFunctionClose, escapeFunctionOpen, existRelation, existSequence, existTable, existView, fetchResultSetSize, getBigDecimal, getBigInteger, getBoolean, getByte, getByteArray, getCACHEkeyWord, getChar, getCharArray, getCharArray, getCharArray, getColumnAliasExpr, getConcatExpression, getCreateSequence, getCreateSequence, getDate, getDate, getDouble, getFirstLocateExpression, getFloat, getFromClause, getFromClause, getINCREMENTkeyWord, getIndexedLocateExpression, getInt, getLengthOperator, getLong, getName, getNextValInSequence, getOboolean, getObyte, getOchar, getOdouble, getOfloat, getOint, getOlong, getOshort, getQuery, getSTARTkeyWord, getSerialized, getShort, getSqlType, getSqlTypeCode, getSqlTypeCode, getString, getSubqueryAlias, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getWhereClause, handleOrderBy, modifySelectClauseWithRange, modifyWhereClauseWithRange, setBigDecimal, setBigInteger, setBoolean, setByte, setByteArray, setChar, setCharArray, setDate, setDouble, setFloat, setInt, setLong, setNull, setOboolean, setObyte, setOchar, setOdouble, setOfloat, setOint, setOlong, setOshort, setSerialized, setShort, setString, sqldate2date, supportBatchPreparedStatement, time2date, timestamp2date, writeColumnAlias, writeTableAlias

Field Details

MYSQLINDEXEDLOCATE

private static final String MYSQLINDEXEDLOCATE


varbinarySize

public int varbinarySize


varbinarySizeInPk

public int varbinarySizeInPk


varcharSize

private int varcharSize


varcharSizeInPk

private int varcharSizeInPk

Constructor Details

MysqlAdapter

public MysqlAdapter()

Method Details

fetchResultSetSize

public int fetchResultSetSize(ResultSet rs)
            throws SQLException
This calculates the size of a result set. If this feature is not supported by a database or its jdbc driver, this method returns -1.
Specified by:
fetchResultSetSize in interface RdbAdapter
Overrides:
fetchResultSetSize in interface BasicRdbAdapter

Parameters:
rs - the result set which the size must be returned


getChar

public char getChar(ResultSet rs,
                    int idx,
                    char nullValue)
            throws SQLException
Get a char value from a ResultSet.
Specified by:
getChar in interface ResultsetAdapter
Overrides:
getChar in interface BasicRdbAdapter

Parameters:
rs - is the result where to get the value
idx - is the index of the value in the resultset
nullValue - represents the nullvalue to return if the column is null in the resultset


getCreateSequence

public String getCreateSequence(String seqName)
            throws UnsupportedOperationException
Specified by:
getCreateSequence in interface SequenceAdapter
Overrides:
getCreateSequence in interface BasicRdbAdapter

Parameters:
seqName - is the sequence name

Returns:
the SQL command to create a sequence


getCreateSequence

public String getCreateSequence(String seqName,
                                Integer startid,
                                Integer inc,
                                Integer cache)
Specified by:
getCreateSequence in interface SequenceAdapter
Overrides:
getCreateSequence in interface BasicRdbAdapter

Parameters:
seqName - is the sequence name
startid - is the initial value of the sequence
cache - is the size of the cache

Returns:
the SQL command to create a sequence


getDate

public Date getDate(ResultSet rs,
                    int idx,
                    String sqlColumnType,
                    Date nullValue)
            throws SQLException
Get a Date value from a ResultSet.
Specified by:
getDate in interface ResultsetAdapter
Overrides:
getDate in interface BasicRdbAdapter

Parameters:
rs - is the result where to get the value
idx - is the index of the value in the resultset
nullValue - represents the nullvalue to return if the column is null in the resultset


getIndexedLocateExpression

public String getIndexedLocateExpression(String instring,
                                         String substring,
                                         String fromIndex)
Specified by:
getIndexedLocateExpression in interface RdbAdapter
Overrides:
getIndexedLocateExpression in interface BasicRdbAdapter


getOchar

public Character getOchar(ResultSet rs,
                          int idx,
                          Character nullValue)
            throws SQLException
Get a Character value from a ResultSet.
Specified by:
getOchar in interface ResultsetAdapter
Overrides:
getOchar in interface BasicRdbAdapter

Parameters:
rs - is the result where to get the value
idx - is the index of the value in the resultset
nullValue - represents the nullvalue to return if the column is null in the resultset


getSqlType

public String getSqlType(int typeCode,
                         boolean usedInPK,
                         int size,
                         int scale)
            throws RdbAdapterException
This method returns the SQL type linked to the java type
Specified by:
getSqlType in interface TypeAdapter
Overrides:
getSqlType in interface BasicRdbAdapter

Parameters:
typeCode - is the type code of the java type
usedInPK - indicates if the type has to be used into a Primary key
size - can indicates the expected size of the type. If it equals to NO_SIZE that means no size is expected. This parameter can be used for float, BigXXX numbers, String,...
scale - can indicates the expected scale of the type. If it equals to NO_SIZE that means no scale is expected.


getSqlTypeCode

public int getSqlTypeCode(int typeCode,
                          String sqlColumnType)
            throws RdbAdapterException
This method returns the SQL type code linked to the java type specified in parameter.
Specified by:
getSqlTypeCode in interface TypeAdapter
Overrides:
getSqlTypeCode in interface BasicRdbAdapter

Returns:
An int constant defined in the java.sql.Types class


modifyWhereClauseWithRange

protected void modifyWhereClauseWithRange(StringBuffer sb,
                                          String _where,
                                          int rangeStart,
                                          int rangeSize)
Overrides:
modifyWhereClauseWithRange in interface BasicRdbAdapter


setDate

public void setDate(PreparedStatement ps,
                    int idx,
                    Date o,
                    String columnType)
            throws SQLException
Assignes a value into a PreparedStatement
Specified by:
setDate in interface PreparedStatementAdapter
Overrides:
setDate in interface BasicRdbAdapter

Parameters:
ps - is the PreparedStatement
idx - is the index of the the value in the PreparedStatement
o - is the value to assign


setVarcharSize

public void setVarcharSize(int s)


setVarcharSizeInPk

public void setVarcharSizeInPk(int s)


supportBatchPreparedStatement

public boolean supportBatchPreparedStatement()
Specified by:
supportBatchPreparedStatement in interface RdbAdapter
Overrides:
supportBatchPreparedStatement in interface BasicRdbAdapter