Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
JDBC and Relational Databases
get column value from column name
Yudi Ono
Greenhorn
Posts: 12
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi..
i want to retrieve column field value after i retrieve column name, but i don't know what to do..
here's my code
String sql_select = "select * from "+rs2.getString("mtab_table_name")+""; String sql_where = " where 1 = 1 "; Statement exec = conn.createStatement(); String a_rs3 = ""+ sql_select +""+ sql_where +" "; logger.info(a_rs3); ResultSet a_rs2 = exec.executeQuery(" "+ sql_select +""+ sql_where +" "); String column_name = ""; String column_value = ""; ResultSetMetaData rsColumns = a_rs2.getMetaData(); int count = rsColumns.getColumnCount(); System.out.println("jumlah kolom =" + count); if(count != 0) { for(int i=1; i<= count; i++) { System.out.println(column_name); if (column_name.equals("")) { column_name = rsColumns.getColumnName(i); } else { column_name = column_name +","+ rsColumns.getColumnName(i); } } }
please help..
regards
Yudi
Balu Sadhasivam
Ranch Hand
Posts: 874
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Is it all the column in the same table or different tables ?
# if (column_name.equals("")) # # { # column_name = rsColumns.getColumnName(i); # } else # { # column_name = column_name +","+ rsColumns.getColumnName(i); # } # }
you can use column_name as
string
in SELECT statement for the table , query the databae . and you get the required columns only,
"SELECT " + column_name + " from table" + " where ..."
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
MetaData Incomplete?
Getting null while trying to get value of Multiple list
MultiDimenaional Array sort
problem while displaying multipage tiff image in applet
Calling the Excel file using Java
More...