• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

retrieve database on new jframe

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can insert into the database's employee table from this frame,
but I want to retrieve the whole table to a new frame by clicking on Retrieve button to show previous table and what i have inserted.
java.JPG
[Thumbnail for java.JPG]
picture of jframe i created
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

What have you tried? Have a look at this tutorial.
 
ahmed taher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//with this code i can retrieve the database table to the output of netbeans, but how can i do it to new jframe

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       try {
           rs = st.executeQuery("select * from employee");
           while (rs.next()) {
               System.out.println("ID: " + rs.getInt("id") + " , Name: " + rs.getString("name") + " , Sallary: " + rs.getInt("sallary"));
           }
       } catch (Exception e) {
           System.out.println("Booooom" + e);
       }    
   }      
java.JPG
[Thumbnail for java.JPG]
 
ahmed taher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you have an answer or not ?
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Campbell asked earlier what you'd tried.

From what you've asked I presume you want to open a new display when the user clicks the Retrieve button?

In which case I would do that bit first.
 
Bartender
Posts: 1251
87
Hibernate jQuery Spring MySQL Database Tomcat Server Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ahmed taher wrote:do you have an answer or not ?

Everyone here on the ranch is a volunteer. Some of them might be busy in office Or just came from work and tired, may be in family function, may be sleeping  etc. Rather writing here redundantly I would request you to please go through Patience Is A Virtue  
 
Ranch Hand
Posts: 235
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ahmed taher wrote:do you have an answer or not ?



I'm sure everyone here has an answer.  You might not like all of them.  Learning and understanding Java requires a lot of time, effort and reading.  Others have pointed you to excellent documents, but I have one more you should look at -- We are not a codemill.  We are more than happy to help you find the answer/solve the problem; but, no one will write your program for you.

As too your question as to getting data from a database and writing it out to a JFrame -- my question for you is, how did you create your data entry form?  Most everything you need to solve your question is in that form.  
 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is how I solve my problem

 
John Joe
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ahmed taher wrote://with this code i can retrieve the database table to the output of netbeans, but how can i do it to new jframe

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       try {
           rs = st.executeQuery("select * from employee");
           while (rs.next()) {
               System.out.println("ID: " + rs.getInt("id") + " , Name: " + rs.getString("name") + " , Sallary: " + rs.getInt("sallary"));
           }
       } catch (Exception e) {
           System.out.println("Booooom" + e);
       }    
   }      



I'm sure you have already declared Textview right ? Just use setText to place the value you get to the TextView.
 
ahmed taher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, i am the good
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic