Results 1 to 2 of 2
  1. #1
    renu is offline Senior Member
    Join Date
    May 2010
    Rep Power

    Question How to create a header from an sql select query in java


    I have to create a header line from a select query and put it in an output file following the records from the query.

    For example ,
    the query looks like this:-

    select name,room_no,cc1200,cc1201,cc1202,cc1203,cc1204,cc 1205 from student;

    The header should look like this

    I only need idea of what to use to get the header i want
    once i have the query , is it good idea to use token with delimiter , (is this idea a good one)
    or using split function is a good idea ?

    The query returns records which will be put into a file, all these records should preceed with a header with the column names changed to name,room_no,00,01,02,03,04,05 ?

    How do i split the query till " FROM " word , so that i can get only the column names .

    Thank You In Advance
    Last edited by renu; 06-21-2011 at 08:10 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    Check your ResultSet.getMetaData() object; it knows about all the columns, their length etc.

    kind regards,

    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. Java DAO create query please help
    By alvin0618 in forum XML
    Replies: 5
    Last Post: 03-31-2011, 07:05 AM
  2. return output from a non select query (java/access)
    By kitiaradl in forum New To Java
    Replies: 2
    Last Post: 04-21-2010, 12:04 AM
  3. return output from a non select query (java/access)
    By kitiaradl in forum New To Java
    Replies: 0
    Last Post: 04-15-2010, 09:01 PM
    By herfnai in forum JDBC
    Replies: 3
    Last Post: 11-24-2008, 12:04 PM
  5. Using a variable in a SELECT FROM WHERE query
    By cplmckenzie in forum JDBC
    Replies: 12
    Last Post: 04-23-2008, 03:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts