Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / October 2004

Tip: Looking for answers? Try searching our database.

Opposite of ResultSetMetaData.getColumnName() ??  Is not: putColumnName()

Thread view: 
Arnold Peters - 16 Oct 2004 18:10 GMT
As well known I can retrieve the column names by a java code similar to the one below.
But how do I put the column names into the database which I retrieve later?
There is no function like putColumnName()

ResultSetMetaData rsmd = rs.getMetaData();
int maxcol = rsmd.getColumnCount();
for(int col=1; col<=maxcol; col++)  
  System.out.println(rsmd.getColumnName(col));

Arni
Joe Weinstein - 16 Oct 2004 18:32 GMT
> As well known I can retrieve the column names by a java code similar to the one below.
> But how do I put the column names into the database which I retrieve later?
[quoted text clipped - 4 lines]
> for(int col=1; col<=maxcol; col++)  
>    System.out.println(rsmd.getColumnName(col));

DatabaseMetaData.getColumns().

Joe Weinstein at BEA

> Arni
Woebegone - 16 Oct 2004 20:15 GMT
> As well known I can retrieve the column names by a java code similar to
> the one below.
[quoted text clipped - 8 lines]
>
> Arni

Are you talking about creating tables/columns in the database? This requires
that you execute an update query consisting of a CREATE or ALTER TABLE
statement with your DDL (and depends on what your DB allows). On the other
hand, if you're just trying to store the names you've gotten for later use,
you could use "String[] columnNames = new String[maxcol];" and inside your
loop "columnNames[i - 1] = rsmd.getColumnName(col);"

HTH,
Sean.
Ann - 17 Oct 2004 03:00 GMT
> As well known I can retrieve the column names by a java code similar to the one below.
> But how do I put the column names into the database which I retrieve later?
[quoted text clipped - 6 lines]
>
> Arni

ALTER TABLE <name> CHANGE COLUMN <oldname> <newname>

or similar
Paul Lutus - 17 Oct 2004 06:34 GMT
> As well known I can retrieve the column names by a java code similar to
> the one below. But how do I put the column names into the database which I
> retrieve later? There is no function like putColumnName()

Tell us what problem you are trying to solve. The database already has field
names. Do you want to change the field names for the database records? To
do this, you normally create an entirely new table.

Signature

Paul Lutus
http://www.arachnoid.com

Oscar kind - 17 Oct 2004 14:20 GMT
In comp.lang.java.help Arnold Peters <apet10@hotmail.com> wrote:
> As well known I can retrieve the column names by a java code similar to the one below.
> But how do I put the column names into the database which I retrieve later?
> There is no function like putColumnName()

No; the meta data classes provide information about the database that is
not always available in a uniform manner using SQL. They are purely for
information only.

To change/add/remove a column in a database, use SQL queries like "alter
table ...".

Signature

Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.