How to use mysql:jfinal data

Source: Internet
Author: User

Preface: It is an honor to encounter a small problem today about Jfinal's Getint (), Getlong () method and MySQL data type Association. If the type of int field in the MySQL database uses unsigned, then jfinal will use Getlong (), and if the Int type field is not unsigned, then jfinal () is used, otherwise the type mismatch error occurs.
Understanding the MySQL data typeFirst, let's look at the MySQL data type, here we only see the type of int

Int[(m)]

Signed values: 2147683648 to 2147683647 (-231 to 231-1)

Unsigned values: 0 to 4294967295 (0 to 232-1) 4 bytes

This means that if your data field is such a child,
' UID ' int (one) not NULL DEFAULT ' 0 ' COMMENT ' user ID '
Then m=11 is correct, because the "-" (negative number) is considered to be the maximum length of 11 bits.
And if your data field is like this,
' UID ' int (one) unsigned not NULL COMMENT ' user ID '
Then m=11 is meaningless, because the maximum length is 10 bits, if you are more professional, at this time, your data field should be like this
' UID ' int (ten) unsigned not NULL COMMENT ' user ID '

If you want to learn more about MySQL Data Insider, please check out the http://www.cnblogs.com/kwishly/archive/2012/04/19/2457450.html article.
Understanding jfinal Data TypesAgain, here we only focus on the Getlong () and Getint () methods.
/**  * Get attribute of MySQL type:int, Integer, tinyint (n) n > 1, smallint, mediumint  */public integer GETINT (String attr) {  return (Integer) attrs.get (attr);}/**  * Get attribute of MySQL type:bigint, unsign int  */public Long Getl Ong (String attr) {  return (Long) attrs.get (attr);}

Note the difference between unsigned int and int。
int data for Java
System.out.println ("2147683647");  System.out.println ("4294967295");  System.out.println (integer.max_value);//2147483647

So you can see why jfinal was designed that way.
Summary: small knowledge, long insight.

How to use mysql:jfinal data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.