You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-dev@db.apache.org by Yauheni Prykhodzka <ya...@pinjaworld.de> on 2006/03/15 09:50:58 UTC

a small extension of the class Column

hi there,

sorry for doing anything wrong but i'm first time
here. :)

i did a small extension of your code. i added the
attribute for the
native data type to the class Column. the native type
is returned  by a
jdbc  driver.  you already use a mapping to return the
native time
calling PlatformInfo.getNativeType(int). my call is
Column.getNativeDataType(), that returns String. jdbc
drive (and my
call) returns different result that you method of
PlatformInfo. it's
important if you want to compare databases. 

so i would like to ask if this is useful for the
projekt? if it's so, how can i add my
code to the project? how does it work?

kindly regards,
yauheni 

Yauheni Prykhodzka
Bussardstr. 16
85716 Unterschleissheim
Deutschland

E-Mail: yauheni.prykhodzka@pinjaworld.de
Tel.:   +49 89 42775646
Handy:  +49 179 6689607
Web:    http://www.pinjaworld.de

Re: a small extension of the class Column

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/15/06, Yauheni Prykhodzka <ya...@pinjaworld.de> wrote:

> i'm developing now a small tool that should compare
> databases (of the same type). I need to get native
> types possibly without any modifications. For example
> the base implementation of DdlUtils returns SMALLINT
> instead of TYNIINT for MySql. Probably i can get
> SMALLINT both for TYNIINT and for some other native
> type if i'll use the current implementation of
> DdlUtils. So the result of the compare can be wrong in
> this case!

The problem is that MySql's TINYINT is not a valid JDBC TINYINT
according to the JDBC spec. Hence, DdlUtils maps it to MySql's
SMALLINT instead.

> I agree with you that isn't a common case. But you
> need to know the native type sometimes.

You might be better off using the JDBC metadata directly which gives
you access to more info that might be of use to you. See the
DumpMetadataTask for reference.

Tom

Re: a small extension of the class Column

Posted by Yauheni Prykhodzka <ya...@pinjaworld.de>.
Hi Thomas,

i'm developing now a small tool that should compare
databases (of the same type). I need to get native
types possibly without any modifications. For example
the base implementation of DdlUtils returns SMALLINT
instead of TYNIINT for MySql. Probably i can get
SMALLINT both for TYNIINT and for some other native
type if i'll use the current implementation of
DdlUtils. So the result of the compare can be wrong in
this case!

I agree with you that isn't a common case. But you
need to know the native type sometimes.

Yauheni

--- Thomas Dudziak <to...@gmail.com> schrieb:

> On 3/15/06, Yauheni Prykhodzka
> <ya...@pinjaworld.de> wrote:
> 
> > i did a small extension of your code. i added the
> > attribute for the
> > native data type to the class Column. the native
> type
> > is returned  by a
> > jdbc  driver.  you already use a mapping to return
> the
> > native time
> > calling PlatformInfo.getNativeType(int). my call
> is
> > Column.getNativeDataType(), that returns String.
> jdbc
> > drive (and my
> > call) returns different result that you method of
> > PlatformInfo. it's
> > important if you want to compare databases.
> >
> > so i would like to ask if this is useful for the
> > projekt? if it's so, how can i add my
> > code to the project? how does it work?
> 
> I'm not entirely sure why you need this? In general,
> the jdbc type of
> a column in a model read from a live database is
> almost always the
> type returned by the jdbc driver. Only on some rare
> cases, DdlUtils
> modifies the type in order to enhance the mapping.
> E.g. Oracle does not have TINYINT, SMALLINT or
> BIGINT types, but
> rather you have to use NUMBER with varying size for
> these. On reading
> a model from an Oracle database, DdlUtils checks the
> size (and scale)
> of these columns (which are returned as NUMERIC) and
> if it encounters
> the exact size specification for
> TINYINT/SMALLINT/BIGINT, it changes
> the jdbc type accordingly.
> 
> Tom
> 


Yauheni Prykhodzka
Bussardstr. 16
85716 Unterschleissheim
Deutschland

E-Mail: yauheni.prykhodzka@pinjaworld.de
Tel.:   +49 89 42775646
Handy:  +49 179 6689607
Web:    http://www.pinjaworld.de

Re: a small extension of the class Column

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/15/06, Yauheni Prykhodzka <ya...@pinjaworld.de> wrote:

> i did a small extension of your code. i added the
> attribute for the
> native data type to the class Column. the native type
> is returned  by a
> jdbc  driver.  you already use a mapping to return the
> native time
> calling PlatformInfo.getNativeType(int). my call is
> Column.getNativeDataType(), that returns String. jdbc
> drive (and my
> call) returns different result that you method of
> PlatformInfo. it's
> important if you want to compare databases.
>
> so i would like to ask if this is useful for the
> projekt? if it's so, how can i add my
> code to the project? how does it work?

I'm not entirely sure why you need this? In general, the jdbc type of
a column in a model read from a live database is almost always the
type returned by the jdbc driver. Only on some rare cases, DdlUtils
modifies the type in order to enhance the mapping.
E.g. Oracle does not have TINYINT, SMALLINT or BIGINT types, but
rather you have to use NUMBER with varying size for these. On reading
a model from an Oracle database, DdlUtils checks the size (and scale)
of these columns (which are returned as NUMERIC) and if it encounters
the exact size specification for TINYINT/SMALLINT/BIGINT, it changes
the jdbc type accordingly.

Tom