db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Segel" <mse...@segel.com>
Subject RE: how to find programatically the max size of a column?
Date Fri, 21 Jul 2006 17:59:03 GMT
Not sure exactly what you are asking....

If you want to find out the limits set on the VARCHAR column, the easiest
way to do this is to query the system tables. This is going to be database
dependent.

Since you also want to allow the "end user" to set the limits at install
time, again you are going to be dealing with DDL which is going to be
platform specific. (Note: Most databases use very similar SQL syntax for
their DDL, however there is no guarantee that they will all conform to the
same syntax....)

Having said that...
You should be able to use the java.sql DatabaseMetaData interface, using the
getColumns() method. This should show you the parameters of the existing
VARCHAR column.

Here is the url to the javadoc...
	
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html


What makes your request confusing is that this is a derby discussion list,
and you're asking for a generic solution.

If you are writing something primarily for Derby that you would like to keep
as generic as possible for future potential migration efforts, then you will
have to consider what sort of functionality you want to allow. 


HTH,

-G

> -----Original Message-----
> From: pierre madiot [mailto:pitonew@yahoo.fr]
> Sent: Friday, July 21, 2006 12:26 PM
> To: derby-user@db.apache.org
> Subject: how to find programatically the max size of a column?
> 
> Hello,
> 
> I have to design a webapp form which would display an
> error message when a <textarea>'s content is beyond
> the maximum size of the back-end Derby's table's
> column.
> 
> The user may at install time choose the size of the
> VARCHAR column.
> 
> in the context of the MVC i'd like to have the C to
> through an error to the V, when it finds out that the
> field content sent from the form is larger than the
> maximal acceptable from the M.
> 
> i'd like to be able to use the jdbc DatabaseMetaData
> API to find out the information dynamically.
> I wasn't able to find how how so far.
> 
> Ideally, i'd like to find a DB independant way to
> retireve this info. I realise this is Derby focus
> list, but our deployment targets 2 other major DBs for
> now (MySQL and Oracle... would you have guess :).
> 
> anyway, thanks for all helps and hints on this.
> 
> cheers
> 
> 
> 
> 
> 
> 
> __________________________________________________________________________
> _
> Découvrez un nouveau moyen de poser toutes vos questions quelque soit le
> sujet !
> Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et
> vos expériences.
> http://fr.answers.yahoo.com




Mime
View raw message