From: shashi kanth <[EMAIL PROTECTED]>
Reply-To: shashi kanth <[EMAIL PROTECTED]>
To: SERVLET-INTEREST@JAVA.SUN.COM
Subject: doubt in oracle high priority
Date: Fri, 11 Feb 2005 11:20:56 -0000
hi All,
Iam using oracle i need to get column width of a table.
i can do it using ResultSetMetaData.getColumnDisplaySize(int i)
but i don't know index of the column number but i know name of
the column
i mean to say is there method with name
ResultSetMetaData.getColumnDisplaySize(String name)
your help is appreciated
There is no direct ResultSetMetaData.getColumnDisplaySize(int i), as you can
see by looking in the API. However, if you look at the API, you will see a
method called ResultSetMetaData.getColumnName(int index); you could use this
in a loop to inspect each column in turn and see if it is the one you want,
then ask for the column's size.
For example, something like this:
while (rs.next()) {
for (int ix=0; ix<rs.getColumnCount(); ix++) {
if (rs.getColumnName(ix).equals("ColumnFoo")) {
int fooSize = rs.getColumnDisplaySize(ix);
System.out.println("The size of ColumnFoo is " + fooSize);
break; //no need to look at remaining columns
}
}
}
Rhino
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html