Retrieve multiple data from database into Table.....
hi...........
I want to Retrieve multiple data from database into Table but i am not able to....
i am only able to retrieve one value not more than that. means
in my database i have attributes pH, phosphate, ....... month, year.........
so its allowing me to retrieve only one value only for one month not more that........
means it wil give (2,3,.........,1,2005) but only for 2005 , i want to retrieve for all the years or for all the months.....
i hope u have understand what i want to tell u..........
plz help?????????
code in java swing...........
View Answers
December 7, 2011 at 5:05 PM
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
public class JTableDatabase {
public static void main(String[] args) {
Vector columnNames = new Vector();
Vector data = new Vector();
JPanel p=new JPanel();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
String sql = "Select * from data";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
for (int i = 1; i <= columns; i++) {
columnNames.addElement( md.getColumnName(i) );
}
while (rs.next()) {
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++){
row.addElement( rs.getObject(i) );
}
data.addElement( row );
}
rs.close();
stmt.close();
}
catch(Exception e){
System.out.println(e);
}
JTable table = new JTable(data, columnNames);
TableColumn col;
for (int i = 0; i < table.getColumnCount(); i++) {
col = table.getColumnModel().getColumn(i);
col.setMaxWidth(250);
}
JScrollPane scrollPane = new JScrollPane( table );
p.add( scrollPane );
JFrame f=new JFrame();
f.add(p);
f.setSize(600,400);
f.setVisible(true);
}
}
Ads
Related Tutorials/Questions & Answers:
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into
Table..... hi...........
I want to
Retrieve multiple data from database into
Table but i am not able to....
i am only able to
retrieve one value not more than that. means
in my
Advertisements
Select data from Table in Database
the selected
data from table in
database. The
select query in the
database retrieve... Select
data from Table in
Database
 ... to
retrieve the
data from table. In
this Tutorial we create a
table country
retrieve data from database with hyperlink
retrieve data from database with hyperlink sir....i have one
table called 'name' having two values i have to
retrieve those
data with a hyperlink... can i do it..help me sir its urgent.......?????
for example-in
table 'name' i
retrieve data from mysql database
retrieve data from mysql database hi am not familiar in php.....even... selected value on combobox which is to be
retrieve the relevant
data from mysql... is stored on testtable
table.
but i need one
data alone. i don,t know where to ask
Data retrieve from mysql database
Data retrieve from mysql database Hi sir,
please give some example of jsp code for retrieving mysql
database values in
multiple dropdown list...
from the dropdown, related
data will get displayed on the textboxes. Here we have
I have to retrieve these data from the field table
I have to
retrieve these
data from the field table Hi. I have a field in
database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to
retrieve these
data from
MYSQL retrieve record from Data table
MYSQL
retrieve record
from Data table Hi. I have a field in
database...,kanchipuram for a single record. I have to
retrieve these
data from the field
table. Actually they are separated by comma. I want to take the values as single
retrieve data from database using jsf
retrieve data from database using jsf Hello
I want an example of source code to
retrieve data from database
i have a
database (oracle) name as db1 it's contain
table 'author' composed of three columns idauthor(primary key
Retrieving value from multiple table in database
Retrieving value
from multiple table in database Hi fnds, I want to maintain the financial
database of 20 users for 1 year and update the details... created 12 tables with
table name - month1,month2,....,upto month12.. each
table
Retrieve data from database in swing application
Retrieve data from database in swing application I want to retrive
data(doctor name,specilization,date)
from my sql
database...();
ResultSet rs=st.executeQuery("select *
from data where id=1");
while
retrieve record from table
retrieve record
from table Hi. I have a field in
database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to
retrieve these
data from the field
table. Actually
retrieve related data from database using jsp and mysql
retrieve related
data from database using jsp and mysql Hi sir,
please give some example of jsp code for retrieving mysql
database values in
multiple dropdown list. if we change a value in a dropdown its related value must
How to Retrieve data from database in jsp
How to
Retrieve data from database in jsp
In this section we will discuss about how to fetch
data from database table.
We will give a simple example which will demonstrate you about fetching
data
from database table.
Example
We
retrieve record from the field table
retrieve record
from the field table Hi. I have a field in
database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to
retrieve these
data from the field
table
How to retrieve record from table
How to
retrieve record
from table Hi. I have a field in
database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to
retrieve these
data from the field
table