• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

retrieve database on new jframe  RSS feed

 
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
 
Marshal
Posts: 60136
188
  • 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 ?
 
Master Rancher
Posts: 3630
40
  • 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.
 
Saloon Keeper
Posts: 1037
43
Eclipse IDE Hibernate jQuery MySQL Database 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 
 
Ranch Hand
Posts: 231
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. 
 
Ranch Hand
Posts: 570
3
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: 570
3
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
Boost this thread!