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

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

    Hi

    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
    name,room_no,00,01,02,03,04,05

    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 09:10 PM.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

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

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Java DAO create query please help
    By alvin0618 in forum XML
    Replies: 5
    Last Post: 03-31-2011, 08: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, 01: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, 10:01 PM
  4. SELECT FROM WHERE query
    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, 04: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
  •