aspose file tools*
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
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: 761

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default varchar length is 255, not 256. Why ?
 
Similar Threads
why table field properties not follow what we set in mapping file ?
Question about the type of JoinColumn.
Dim of Array
Create table failure
Only 256 chars stored in DB field