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



Home Answers Viewqa Applet retrieving data in to the dropdown box from postgresql database in core java

Have Programming Question? Ask it here!
 
 
 


anu
retrieving data in to the dropdown box from postgresql database in core java
1 Answer(s)      3 years and 5 months ago
Posted in : Applet


hi., i just need to correct my codes.somebody help me to clear the error to bring a right of codes to execute.Thanks in advance.
//first page
    import java.awt.*;
    import java.sql.SQLException;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    class gwf extends Frame implements ActionListener
    { 
        public Label l1,l2,l3;
        public TextField tf1,tf2,tf3;
        public JComboBox c1,c2;
        public Button b1,b2;
        public Panel p1,p2;
        String s1,s2;
        gwf()
        {    setLayout(new GridLayout(5,1));
             setTitle("FIRST PAGE");
            l1 = new Label("Choose Department");
            c1 = new JComboBox();
            c1.addItem("--select--");
            c1.addItem("Welfare");
            c1.addItem("Revenue");
            c1.addItem("State office");
            c1.addItem("Public");
            c1.addItem("Corporation");
            p1 = new Panel();
            p2 = new Panel();
            b1 = new Button("SUBMIT");
            p1.add(l1);
            p1.add(c1);
            p2.add(b1);
            add(p1, "Center");
            add(p2, "South");
            b1.addActionListener(this);
            setSize(500, 500);
            setVisible(true);
        }
        public void actionPerformed(ActionEvent e) 
        {
            gwf1 gw = new gwf1(s1);
            dispose();
        }
        public static void main(String[] args) throws SQLException 
        {
            gwf g = new gwf(); }
//second page
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;

    class gwf1 extends Frame implements ActionListener
    {
        private static final String String =null;
        Label l1;
        TextField t1;
        JComboBox c1,c2;
        Panel  p1,p2;
        Button b1;
        String s1, s2;
        Statement st;
        ResultSet rs;
        Connection con;
      public void apply()
       {
        try
           {
                Class.forName("org.postgresqlANSI.Driver");
            con = DriverManager.getConnection("jdbc:postgresqlANSI://localhost:5432/departments","postgres", "postgres");
            ResultSet rs=st.executeQuery("SELECT role_name from role WHERE dept_id=1234");
                if(rs!=null)
                {while(rs.next())
                {
                   c1.addItem(rs.getString("role_name"));
                }
                }
           }
           catch(Exception e)
           {
                 e.printStackTrace();
           }
       }
        public gwf1(String s1)
        {
            this.s1 = s1;
            setLayout(new GridLayout(5, 1));
            setTitle("Second Page");
            l1 = new Label("Enter Role");
            c1 = new JComboBox();
            c1.addItem("--select--");
            b1 = new Button("SUBMIT");
            p1 = new Panel();
            p2 = new Panel();
            p1.add(l1);
            p1.add(c1);
            p2.add(b1); 
            add(p1, "Center");
            add(p2, "South");
            b1.addActionListener(this);
            setSize(400, 500);
            setVisible(true);
          }
        public void actionPerformed(ActionEvent e1) 
        {
            JOptionPane.showMessageDialog(this, "The generated Id is:");
            dispose();
            gwf2 gp = new gwf2();
        }
    }

Advertisement
View Answers

March 14, 2011 at 11:57 AM


We have used Mysql database:

import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class  JComboBoxExample{
    public static void main(String[] args){
        JFrame f=new JFrame();
        f.setLayout(null);
        JLabel lab=new JLabel("Course Items:");
        final JComboBox combo=new JComboBox();
        combo.addItem("--Select--");
        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 student");
           while(rs.next()){
           combo.addItem(rs.getInt("id"));
           }
        }
        catch(Exception e){}
        JButton b=new JButton("Get");
        lab.setBounds(20,20,100,20);
        combo.setBounds(120,20,150,20);
        b.setBounds(120,50,80,20);
        b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        String value = combo.getSelectedItem().toString();
        JOptionPane.showMessageDialog(null,"You have selected '"+value+"' from ComboBox");
         }
        });
        f.add(lab);
        f.add(combo);
        f.add(b);
        f.setVisible(true);
        f.setSize(300,120);
    }
}


Related Tutorials/Questions & Answers:
retrieving data in to the dropdown box from postgresql database in core java
retrieving data in to the dropdown box from postgresql database in core...=st.executeQuery("SELECT role_name from role WHERE dept_id=1234"); if(rs... database: import java.sql.*; import java.awt.*; import javax.swing.*; import
Retrieving Data from Database to fill Combo Box
Retrieving Data from Database to fill Combo Box  Sir, I have a JSP Page with a combo box and a label. I have a database that has two fields id and an image. Now I want to fill the combo box with image and on selecting
Advertisements
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  Hi, how to dynamically increase size of list box in javascript when elements retrieving from database.. That is whenever I
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  hi all, how can i insert elements into java script list box retrieving from Database. whenever I insert any element in the Db
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please... of the server it has to display the process name from database into the process name... combo box is there and another filed is version of the server(like 1.0,2.0) like
retrieving from oracle database using jsp combo box
retrieving from oracle database using jsp combo box  hi this is my... name of the server has to display in the process name field from the oracle database please help on this i need code using servlets please help me . <
how to check dates while retrieving data from database
how to check dates while retrieving data from database  i want to update database record based on delivery date i have tried this query but it wont work b="update deliveryorder set prtnm='"+arr[1]+"',stn='"+arr[0]+"',sbston
store dropdown box values in database server
store dropdown box values in database server  how to store dropdown box values in database server in jsp
The code for retrieving data from database into Drop Down List.
The code for retrieving data from database into Drop Down List.  <% DataSource data = new MysqlDataSource(); Connection con... to MySQL"); PreparedStatement pre = con.prepareStatement("select * from
retrieving data from database to the textbox depending upon the id in jsp
retrieving data from database to the textbox depending upon the id in jsp  Hi, our project involves fetching of data from database into textbox... will be checked to database weather it exist or not and if it exists
Excel File data upload into postgresql database in struts 1.x
Excel File data upload into postgresql database in struts 1.x  Dear members please explain how Excel Files data upload into postgresql database in struts 1.x
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp ... get dynamically from the database and whenever a new person has registered his... in storing them into the database,this registration form contains name
JSP Get Data Into Dropdown list From Database
JSP Get Data Into Dropdown list From Database In this section we will discuss... data from the database and set it into the dropdown list in JSP using MySQL.... This tutorial explains you that how to fetch data from database and set
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... combo box which will then load the next combo box values, now i know how to populate the first one, and then how to send the data off to a servlet and preform
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking... getting data into textarea from database table by clicking on the button
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc  how to make a radio button selected when retrieving data from database using struts framework and spring jdbc
retrieving xml document from database
retrieving xml document from database  Hi Guys, I want to retrieve the xml document stored in the database on to a jsp page using jdbc/odbc connnection.Please help me in implementing this feature. Thank You Madhu
Retrieving JTree structure from database
the steps required to create tree retrieving the data from the database. Here... Retrieving JTree structure from database       This example shows how to retrieving data from
Retrieving specific data from excel
Retrieving specific data from excel  Hello everyone, i have written a simple code to retrieve data from excel sheet and working fine, the excel file... first sheet from the workbook HSSFSheet sheet = workbook.getSheetAt(0
dropdown box
dropdown box  i need to have country,state and city in drop down box using ajax and use db2 database   Have a look at the following link: JSP dependent dropdown
Use of Select Box to show the data from database
Use of Select Box to show the data from database   ... from database This example will describe you the use of Select Box in a JSP page to show the data fetched from the database. We are using Servlet to get data
Retrieving the Image from a database Table
Retrieving the Image from a database Table Consider a case where we want... from the database table our java program need to make a connection... to retrieve the image from the database table. You can do it very easily after
Acees data from database using combo box - JSP-Servlet
Acees data from database using combo box  please let me how i access the data from database when i select combo box combo2 having values Arts, Commerce, Science. this combo box will appear when first combo box class_name having
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
populate dropdown box
populate dropdown box  hi, Is there any ways in which i can populate my dropdown menu with values from 1 to n (n = the value stored in database... item in dropdown menu is 10 then the second dropdown box should contain values
check radio button on retrieving the value from database.
check radio button on retrieving the value from database.  HI i am new to jsp.In my applcation i having a problem. I am retrieving user payment from... information from database the i want to show cash radio button checked.How can i do
3 dropdown list from the database using JSP
3 dropdown list from the database using JSP  Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page...; This tutorial shows you how to connect to MySQL database and retrieve the data from the database. In this example we will use tomcat version 4.0.3 to run our
Retrieving value from multiple table in database
Retrieving value from multiple table in database  Hi fnds, I want to maintain the financial database of 20 users for 1 year and update the details... contains the data like name,amount,paiddate and balance of individual users... i
dropdown box in jsf - Java Server Faces Questions
dropdown box in jsf  Hi friends, 1.how to create dropdown boxes in jsf. 2.if the dropdown box contains id values like 1,2,3,4..........,if i click... for above queries. And one more how to create morethan one dropdown box in one jsf
Dropdown code to retrieve result from oracle database
that will retrieve values from the database into dropdown. As the user choose any option from the dropdown, corresponding values will get displayed in the textboxes...Dropdown code to retrieve result from oracle database  Hi Friends, I
Jdbc connectivity in java to oracle for retrieving data between two dates
Jdbc connectivity in java to oracle for retrieving data between two dates ... dates from the database table. I am using combo box to get the date. Problem is arise when i get date from data base in the format such as 10/04/2012 00:00:00
action for dropdown box - Java Server Faces Questions
for populating a list box from a drop-down selection? What I want to do is give... a selection from the drop-down list, the list box beside it gets populated... from my table. When the user selects one catagory, the list box gets populated
dropdown box in jsf - Java Server Faces Questions
dropdown box in jsf  Hi friends, AssigningJob... in dropdown box
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
Search data from database - Java Beginners
Search data from database  Hi Deepak, This is not correct code... searching)in name text box than all data should be displayed in another page related to user name. (means search all field from database and display using
displaying data for a single column from Mysql database in the list box in php form
displaying data for a single column from Mysql database in the list box in php form  I have a form in php.want to display data from a single column...; $data = @mysql_query("select * from names"); echo "Select a Name: n"; echo "<
how i conditional access the data from database using combo box. - JSP-Servlet
how i conditional access the data from database using combo box.   i have combox box named class when i select its value 11 or 12, another combo box... access the data from database when i select class 11 0r 12. Here is JSP file
retrive data from database?
retrive data from database?  hellow i have a database sheet name... from db1 and enter value in text box according there name,rollno and save... as |------------------------| |sn.|rollno|name|text box
Retrieving Data from the table using PreparedStatement
to fetch the data from the database in the table from our java program using... Retrieving Data from the table using PreparedStatement...() method of the PrintWriter class. We can retrieve the data from the database only
how to retrieve data into combo from database in java applet?
how to retrieve data into combo from database in java applet?  hi,. i have written applet codes for linking two frames and database connectivity but the problem is, the database is not retrieving data into the combo..please
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want to work in one page... Pl response.. I do not need getParameter... Pl respose me
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
retrieving newly added records from mssql database and display in a jsp
retrieving newly added records from mssql database and display in a jsp ... from mssql database table and display those records in a jsp.And i have to delete these 10 records from the jsp and retrieve the next recently added 10 records
 

 

 

DMCA.com