Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC plz help me to create gui using Java netbeans
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


haritha
plz help me to create gui using Java netbeans
1 Answer(s)      4 years ago
Posted in : JDBC


Hi, I am unable to fetch a particular data from DB.I am using netbeans for creating GUI. If I want to fetch a particular value like '6', it is calling all the data which contains 6. I am unable to fetch the particular data. Plz help me


Advertisement
View Answers

November 29, 2010 at 10:41 AM


Hi Friend,

Try the following code:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class  Retrieve{

    public static void main(String[] args){
    JFrame f=new JFrame();
    JLabel label1=new JLabel("Name: ");
    JLabel label2=new JLabel("Address: ");
    JTextField text1=new JTextField(20);
    JTextField text2=new JTextField(20);
    try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from data where id=1");
           String name="",address="";
           if(rs.next()){
               name=rs.getString("name");
               address=rs.getString("address");
           }
           text1.setText(name);
           text2.setText(address);
          }
        catch(Exception e){
        }
        JPanel p=new JPanel(new GridLayout(2,2));
        p.add(label1);
        p.add(text1);
        p.add(label2);
        p.add(text2);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}

Thanks



Related Tutorials/Questions & Answers:
plz help me to create gui using Java netbeans
plz help me to create gui using Java netbeans  Hi, I am unable to fetch a particular data from DB.I am using netbeans for creating GUI. If I want.... I am unable to fetch the particular data. Plz help me   Hi Friend
plz help me - Java Beginners
plz help me  Hi, I want to search all field from database using name, and display in text box, then data is update and delete. i want to search name using alphabets a-z, plz reply fast. plz help me this is very urgent
Advertisements
plz help me - Java Beginners
plz help me  Deepak I can write a sessioon code plz help me admin_home.jsp page is display but data is not disply plz help me what is wrong
plz help me - Java Beginners
plz help me  deepak hw can i create a data grid in jsp and also how can i connect to the data base plz help me  to create data grid in jsp... : //import statment for java.sql.* using directives
plz Help me - Java Beginners
plz Help me  Hi, I want learn struts,I dont have any idea about this plz help how can i make a framework.If u have any information then plz send my personal id plz tell me that whose software installed.and give me brief
plz help me - Java Beginners
plz help me  Thanks deepak continue response..i face some problem i... is true...but i very confuse that how it is not displayed admin page plz any one give me reponse my persinal given id  Hi ragni, i am sending
Gui plz help
Gui plz help   Create a Java application that would allow a person to practice math (either addition, subtraction, multiplication or division... far. so basically what i did is i used the java palletes to make a application
plz help me today plz plz - Java Interview Questions
plz help me today plz plz  2.) Suppose list is an array of six elements of type int. What is stored in list after the following java code executes? . for (i = 0; i < 5; i++) { list[i] = 2 * i + 5
Login Form with Java GUI using Netbeans
Login Form with Java GUI using Netbeans  Hi there! I'm a beginner in Java. I've created 2 class files: 1) TestAssign.java 2) NewFrame.java How can I...-if statement and create a new frame for both of the manager and staff
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
Help me quickly plz??
Help me quickly plz??  Can you help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers plz help quickly
Help me plz in Probablity distribution of Java
Help me plz in Probablity distribution of Java  Hello, I have...% is insert or update queries. Which distribution to use and how to achieve it.. Plz help thanks for your time
help me plz - Java Interview Questions
help me plz  1)write a java program that prompts the user to input a decimal number and print the number rounded to the nearest integer? 2)write...? plz answer my question   Hi Friend, Try the following code: 1
Plz help me with this Question - Java Beginners
Plz help me with this Question  this is java code ------------------------- Consider the following code: int [ ] a = [1, 2, 3]; Object o ="123"; String t = "12"; String w = t + "3"; Boolean b = o.equals (a); Boolean b2
plz help me to write a snake game using swings - Swing AWT
plz help me to write a snake game using swings  write snake game program using swings
java, plz help me in doing this - Java Beginners
java, plz help me in doing this  # Write a small record management application for a school. Tasks will be Add Record, Edit Record, Delete Record.....giving me the error of NoClassDefFoundError
Help Me With This Plz - Java Interview Questions
Help Me With This Plz  Write a program that's print a word like(I S E) on the black screen with 0,1 only by using two dimensional array? the 1's will represent the words
plz help me - Java Interview Questions
plz help me  1)Rewrite the method in exercise 10 such that it use... " you should solve this problem in two ways: using iteration and recursion 2... . use linear search for this algorithm .then test your method in java application
plz help me for this question
plz help me for this question  Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 ? 200; 3x1 + 5x2 ? 150; 5x1 + 4x2 ? 100; 8x1 + 4x2 ?? 80, x1 ? 0, x2 ? 0
Plz Help Me
Plz Help Me  Write a program for traffic light tool to manage time giving between Main-Street and sub-Street. firstly, give green light for 40... traffic light on the frame. We have used java swing. It may help you. import
Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
plz help me!!!!!!!! - JSP-Servlet
plz help me!!!!!!!!  i`ve set the environment varaibles for tomcat... there are compilation errors.. plz do help me.   make sure that you did... html file,.java file and xml file.. under which directory or folder i`ve to save
unable to display image using html tag in servlet.(image src is in a variable.....). i am using netbeans IDE. plz..........do help
unable to display image using html tag in servlet.(image src is in a variable.....). i am using netbeans IDE. plz..........do help  import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException
Intranet Website creation - plz help me
Intranet Website creation - plz help me   hi.. I have assign with the intranet website creation work..right from scratch to end..And honestly I know nothing about it.My domain is totally different .. can anybody pls help me
facing problem plz help me out - Framework
Facing problem plz help me out  hi i am new to servlet i deployed... the web.xml file too parallel to the classes folder now i am facing this problem.plz tell me what to do... error:The requested resource (Servlet servlet
Using netbeans 6.9.1 create a mobile app. J2ME.
Using netbeans 6.9.1 create a mobile app. J2ME.   Can anybody help me with my school's project? I need to create a mobile pizza ordering app. Using just checkboxes to select sizes, crusts, topping, shape
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
Advertisements
 

 

 

DMCA.com