473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

JTable...............

Hi........ to all

I hav created the table in the applet window using JTable... i hav to store the retrived data from database in the table..consider if the table contains 3rows i hav insert all the 3 rows ..... Is it possible... if so.. can u explain me..how.....


Regards
Pradeep
Oct 4 '07 #1
4 1284
r035198x
13,262 8TB
Hi........ to all

I hav created the table in the applet window using JTable... i hav to store the retrived data from database in the table..consider if the table contains 3rows i hav insert all the 3 rows ..... Is it possible... if so.. can u explain me..how.....


Regards
Pradeep
Of course it's possible. When the saved button is clicked, just execute an insert statement.
Oct 4 '07 #2
Of course it's possible. When the saved button is clicked, just execute an insert statement.
Thanks..

can u explain with a small example .....

Regards
Pradeep
Oct 4 '07 #3
r035198x
13,262 8TB
Thanks..

can u explain with a small example .....

Regards
Pradeep

What do you have so far?
Oct 4 '07 #4
What do you have so far?
Sorry sir.. yesterday due to network problem.. i can't able to continue the discussion...... i hav to insert data into the table....
consider if the database contains 3 rows.. i hav to insert all the three rows...
can u say how to get all the rows.. from the database..

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import java.sql.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import sun.jdbc.odbc.*;   
  6. import javax.swing.*;
  7.  
  8. public class Tab extends Frame implements ActionListener
  9. {
  10.    JTable table;
  11.    Label l1;
  12.    Button view,exit;
  13.    Connection con;
  14.    ResultSet rs;
  15.    Statement stmt;
  16.    String s,M;  
  17.  public Tab()
  18.  
  19.  {
  20.      super("Table");
  21.     setSize(700,700);
  22.     setLayout(null);
  23.     setBackground(new java.awt.Color(245, 117, 105));
  24.  
  25.      table = new JTable(7,8);
  26.      l1=new Label("TABLE");
  27.      l1.setBounds(20,60,100,70);
  28.      table.setBounds(30,180,650,114);
  29.      exit= new Button("Exit");
  30.      exit.addActionListener(this);
  31.      exit.setBounds(360,580,100,40);
  32.  
  33.  
  34.      add(l1);
  35.      add(table);
  36.       add(exit);
  37.      setVisible(true);
  38.  
  39.  
  40.  
  41.  addWindowListener(new WindowAdapter(){
  42.   public void WindowClosing(WindowEvent w) {System.exit(0);}});
  43.     }
  44.  
  45.  
  46.  
  47.  public void actionPerformed(ActionEvent ae)
  48. {
  49.  int flag=0;
  50.  if(ae.getSource()==view)
  51. {
  52.  
  53. try 
  54. {
  55.  
  56.       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  57.       con=DriverManager.getConnection("jdbc:odbc:prism");
  58.       stmt=con.createStatement();
  59.       rs=stmt.executeQuery("select * from Melting");
  60.  
  61.  
  62.       while(rs.next())
  63.      {
  64.  
  65.         s=(rs.getString(1));
  66.  
  67.        }     
  68. }
  69. catch(ClassNotFoundException e)
  70. {
  71.   System.out.println(e);
  72. }    
  73. catch(SQLException e)
  74. {
  75.   System.out.println(e);
  76. }
  77.  }
  78.   if(ae.getSource()==exit)
  79.   {
  80.      System.exit(0);
  81.   }
  82.  }
  83.   public static void main(String args[]) 
  84. {
  85.  
  86.       Tab pu=new Tab();
  87.   }
  88. }
Oct 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ben Munday | last post by:
Hi all, I have a problem with a Checkbox in a JTable. When i add the Checkbox into the JTable it displays the String representation of the Checkbox, which is not what i want. So, i created a...
1
by: asd | last post by:
I need to make the cells in the 1st column look like the column header. I tried the following code but it didn't change anything: private void rendererTest() { TableColumn column =...
1
by: raysaun | last post by:
I am trying to set a TableCellEditor for a JTable, however, the editor never seems to get called. I can not even get a simplified version (below) to work. When I put a breakpoint on the return...
0
by: sivaprasad06 | last post by:
Hi, I have a editable combo box editor as a cell editor for JTable. I want use only key board to enter data into jtable. so i am using ALT+Down comobination for making cell editiable in the...
5
by: moizpalitanawala | last post by:
Hello friends, How to add data to JTable from a .txt file. I had seen this code from one of the tutorial from java.com. This code doesnt take any input. But shows what is written in the array....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.