Q:

Is there a way to URL shortening in Java to store conveniently into databases

I have requirement where as an attachment user can add a link from sharepoint
So that we can save the link[path] of the attachment instead of actual attachment.
For this we are planning to design a column which is varchar(512) . Intially
we thought this would fit any type of URLs effectively ,but sometimes we found this is too tight
for saving into Databases. My points are

Is this a correct design .
We plannned to use TinyURL.com but we cannot gurantee all users have Internet(target users are with in org can or cannot access Internet). So ruled out this option.
Does java provides any API for shortening URLs.

Thanks in advance

A:

In general, URLs cannot be shortened without removing useful information. Services such as TinyURL.com work by maintaining a database of "short URL" to "full URL" mappings. If you want to shorten URLs you would need to implement something like this yourself internally, so a separate table would be required anyway to hold this mapping. You would be just moving the problem somewhere else.
I guess you will just need to define a suitable URL length limit and define your column accordingly.

