Re: Data type mapping in mysql

Mark Matthews <[email protected]> Tue, 10 Jan 2017 09:16:52 -0600
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>

On 01/10/2017 12:39 AM, Santlal J Gupta wrote:
> Hi,
>
> I am new to Mysql datatype.I have created table with FLOAT data type.
> I saw in MysqlDefs class that Float is map to FIELD_TYPE_FLOAT in " mysqlToJavaType(String mysqlType)" method and then again FIELD_TYPE_FLOAT is map to Types.REAL in "mysqlToJavaType(int mysqlType)" method
>
> I have below question:
> Why FIELD_TYPE_FLOAT is mapped to Types.REAL, can it be mapped to Types.FLOAT instead of Types.REAL?

Hi,

It's because even though MySQL uses the word "FLOAT" to describe this 
type, the type actually fits the SQL standard type of REAL in terms of 
how it works (storage/precision). One can always get data type 
conversion via calling the type-specific getters in ResultSet, or 
passing the desired class in the variants of ResultSet.getObject() that 
take a Class<?> parameter.

   -Mark

-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/java