aspose file tools
The moose likes JDBC and Relational Databases and the fly likes Default varchar length is 255, not 256. Why ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Default varchar length is 255, not 256. Why ?" Watch "Default varchar length is 255, not 256. Why ?" New topic
Author

Default varchar length is 255, not 256. Why ?

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 774

I'm using openJPA with apache derby.

If I do not specify the actual width of the varchar field, it automatically
maps a String field to a varchar(255).

My question: why 255, and not 256 (since 256 is a power of two) ?
Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
I'm guessing since the count is 0 based. 0-255 = 256 possible values.
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
The length of the varchar is stored as a byte by the RDBMS. This makes the possible range of 8-bit values 0-255.
 
rocket mass heater kickstarter
 
subject: Default varchar length is 255, not 256. Why ?