• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieve database on new jframe

 
ahmed taher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Sheriff
Posts: 51453
87
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
do you have an answer or not ?
 
Dave Tolls
Ranch Hand
Posts: 2112
16
  • Mark post as helpful
  • send pies
  • 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.
 
Ganesh Patekar
Bartender
Posts: 696
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Likes 2
  • Mark post as helpful
  • send pies
  • 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 
 
Robert D. Smith
Ranch Hand
Posts: 216
5
  • Mark post as helpful
  • send pies
  • 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. 
 
John Joe
Ranch Hand
Posts: 55
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is how I solve my problem

 
John Joe
Ranch Hand
Posts: 55
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks, i am the good
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic