Home Answers Viewqa JDBC insert data using drop down box in java into database postgresql

 
 


Isha Sachdeva
insert data using drop down box in java into database postgresql
0 Answer(s)      10 months ago
Posted in : JDBC

can you help me out !!.......i wanna to know the appropriate java syntax to insert 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

package blog.forms;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.Attributes.Name;

import org.apache.wicket.extensions.yui.calendar.DateField;
import org.apache.wicket.extensions.yui.calendar.DatePicker;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.upload.FileUploadField;
import org.apache.wicket.model.Model;

import blog.main.Loginn;
import blog.main.MainPage;

public class form1a extends WebPage {
    //private FileUploadField upload;
    private Integer eid;
    //private Model model;

    final TextArea fathername = new TextArea("empfathername", new Model());
    final TextArea Designation = new  TextArea("empdesignation", new Model());
    final TextArea name = new  TextArea("empname", new Model());
    **final Model model = new Model();
    List officenames = new ArrayList();
    DropDownChoice officename = new DropDownChoice("officename", model, officenames);**
    //final TextArea OfficeName  = new  TextArea("officename", new Model());
    final TextField<java.util.Date> DOB = new  TextField<java.util.Date>("BirthDate", new Model());

    final TextField DOR = new  TextField("RetireDate", new Model(), Date.class);

    final TextField PensionFraction = new  TextField("pensionfraction", new Model());
    final TextArea TreasuryNameAddress = new  TextArea("treasurynameandaddress", new Model());
    final TextArea BankNameAddress = new  TextArea("banknameandaddress", new Model());
    final TextField BankAccountNo = new  TextField("BankAccountNo", new Model());
    final TextArea AccountOffice = new  TextArea("accountoffice", new Model());
    final TextField Place = new  TextField("place", new Model());
    final TextField date = new  TextField("quoteDate", new Model(), Date.class);
    //final TextField Signature = new  TextField("sign", new Model());
    final TextArea PresentAddress = new  TextArea("presentpostaladdress", new Model());
    final TextArea RetireAddress = new  TextArea("addressafterretirement", new Model());

        public form1a(Integer emp_id) {

                        eid=emp_id;


        Form form = new Form("f"){
                        protected void onSubmit(){
                            String sym = (String) model.getObject();


                            DateFormat format=new SimpleDateFormat("dd-mmm-yyyy");  
                            Date date = (Date) new Model().getObject();
                            //date = (Date)format.parse(strDate); 


                            doupdate();
                            setResponsePage(new MainPage(eid));
                System.out.println(name.getDefaultModelObjectAsString());
            }
        };
        date.setRequired(true);
        date.add(new DatePicker());

        DOB.setRequired(true);
        DOB.add(new DatePicker());

        DOR.setRequired(true);
        DOR.add(new DatePicker());

        **officenames.add("National Information Centre");
        officenames.add("Ministry of Communications & Information Technology");
        officename.setRequired(true);
        form.add(officename);**
        form.add(name);
        form.add(fathername);
        form.add(Designation);

        form.add(DOB);
        form.add(DOR);
        form.add(PensionFraction);
        form.add(TreasuryNameAddress);
        form.add(BankNameAddress);
        form.add(BankAccountNo);
        form.add(AccountOffice);
        form.add(Place);
        form.add(date);

        form.add(PresentAddress);
        form.add(RetireAddress);
        add(form);


    }


    private void doupdate()
    { 
    //String datetext = DOB.getText();



        //java.sql.Date v5 = new java.sql.Date(new java.util.Date().getTime());
    // java.sql.Date v6 = new java.sql.Date(new java.util.Date().getTime());
     //java.sql.Date v13 = new java.sql.Date(new java.util.Date().getTime());
          String v1=name.getInput();
           String v2=fathername.getInput();
           String v3=Designation.getInput();
           **String v4=officename.getInput();**
           java.util.Date DOB1 = new java.util.Date();
           String v5 =DOB.getInput();
           SimpleDateFormat sd = new SimpleDateFormat("dd/mm/yyyy");
           java.util.Date DOR1 = new java.util.Date();
           String v6 =DOR.getInput();
           SimpleDateFormat sd1 = new SimpleDateFormat("dd/mm/yyyy");


            //java.sql.Date sqlDate = new java.sql.Date(DOB1.getTime());

         // Date v5 =java.sql.Date.valueOf(DOB.getInput());
           Integer v7=Integer.parseInt(PensionFraction.getInput());
           String v8=TreasuryNameAddress.getInput();
           String v9=BankNameAddress.getInput();
           Integer v10=Integer.parseInt(BankAccountNo.getInput());
           String v11=AccountOffice.getInput();
           String v12=Place.getInput();
           java.util.Date date1 = new java.util.Date();
           String v13 =date.getInput();
           SimpleDateFormat sd2 = new SimpleDateFormat("dd/mm/yyyy");

           String v15 = PresentAddress.getInput();
           String v16 = RetireAddress.getInput();
            try {

            Class.forName("org.postgresql.Driver");
            Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/pension/form1a",
                    "postgres", "postgres");
             // String emp_id = l.getUname();
            String sql="update form1a SET name=?,fathername=?,designation=?,officename=?,dob=?,dor=?,pf=?,treasury=?,banknameadd=?,bankaccno=?,acc_office=?,place=?,date=?,paddress=?,raddress=? WHERE emp_id='"+eid+"'";
              PreparedStatement prest = conn.prepareStatement(sql);


                DOB1 = sd.parse(v5);
                DOR1 = sd1.parse(v6);
                date1= sd2.parse(v13);
            /*Statement st=conn.createStatement();
            ResultSet rs=st.executeQuery("select name from form1a where emp_id='"+emp_id+"'");
            if(rs == null)
            {*/

            //String sql="insert into form1a values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
              java.sql.PreparedStatement pst = conn.prepareStatement(sql);
              pst.setString(1, v1);
              pst.setString(2, v2);
              pst.setString(3, v3);
              **pst.setString(4, v4);**          
              //pst.setDate(5,new java.sql.Date( DOB1));
              pst.setDate(5, new Date(DOB1.getTime())); 
              pst.setDate(6,new Date(DOR1.getTime()));
              pst.setInt(7, v7);
              pst.setString(8, v8);
              pst.setString(9, v9);
              pst.setInt(10, v10);
              pst.setString(11, v11);
              pst.setString(12, v12);
              pst.setDate(13,new Date(date1.getTime()));
              pst.setString(14, v15);
              pst.setString(15, v16);
              pst.executeUpdate();
              pst.close();
            }
            catch(Exception e){
                throw new RuntimeException(e);

            }
}
    }





**HTML code of it:-**


<html xmlns:wicket="...">
<head><title>Form 1-A</title>
 <link rel="stylesheet" type="text/css" href="css/Log.css">

</head>
<body topmargin='0' leftmargin='0' rightmargin='0' bgcolor='white' onload="scroll()">

<form wicket:id="f">

<table border='1' width='80%' cellspacing='2' cellpadding='6' align='center'>
<tr>
    <th colspan='4'  bgcolor='#0e1f5b'>
       <font size=3 color="#FFFFFF">
          <u>FORM 1-a</u>
          <br>
    FORM OF APPLICATION COMMUNICATION OF AFRACTION OF SUPPERANNUATION PENSION WITHOUT MEDICAL EXAMINATION WHEN APPLICANT DESIRES THAT THE PAYMENT OF THE
    COMMUTED VALUE OF PENSION SHOULD BE AUTHORISED THROUGH THE PENSION PAYMENT ORDER.
      </font>
      <br>
      <font size=2 color="yellow">
    [See Rules 5(2), 12, 13 (3), 14 (1) and 15(3)]
     <br>
    (To be submitted in duplicate at least three months before the date of retirement)
      </font>
   </th>
</tr>       
<tr>
    <th colspan='4' bgcolor='white' align='left'>
        <font size=2 color="black">
        <br>
        <br>
   The Head of Office,
   <br>
   Ministry of Communication & Information Technology,
   <br>
   Department of Information Technology,
   <br> 
   National Informatics Centre,
   <br>
   A-Block, C.G.O. complex,
   <br>
   Lodi Road, New Delhi - 110 003.
   <br>
   <br>
    &nbsp;&nbsp;&nbsp;      Subject:- Communication of Pension without medical examination.
   <br>
   <br>
   Sir,
   <br>
   <br>
   <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I desire to commute a fraction of my pension in accordance with the
   provision of the Central Civil Services Commutation of Pension Rules,1981.
   The necessary particulars are furnished below:
            </font>
      </th>
</tr>
<tr>
    <td width=45% >
        <b>&nbsp;&nbsp;&nbsp;1.Name (in BLOCK letters)</b>
    </td>
    <td width=55%>
        <textarea wicket:id="empname" cols='50' class='normal' name='empfathername'></textarea>
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;2.Father'sname (and also husband's name in the case of a female Govt. servant)</b>
    </td>
    <td width=55%>
        <textarea wicket:id="empfathername" cols='50' class='normal' name='empfathername'></textarea>
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;3.Designation</b>
    </td>
    <td width=55%>
        <textarea wicket:id="empdesignation" cols='50' class='normal' name='empdesignation'></textarea>
    </td>
</tr>
**<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;4.Name of Office/Department/Ministry in which employed</b>
    </td>
    <td width=55%>
        <select wicket:id="officename">
            <option>National Informatics Centre</option>
            <option>Ministry of Communications & Information Technology</option>
        </select>
    </td>
</tr>**
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;5.Date of Birth (by Christian era)</b>
    </td>
    <td width=55%>
        <input type="text" wicket:id="BirthDate">
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;6.Date of Retirement on superannuation or on the expiry of extension in service granted under FR 56(d).</b>
    </td>
    <td width=55%>
        <input type="text" wicket:id="RetireDate">
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;*7.Fraction of superannuation pension proposed to be commuted</b>
    </td>
    <td width=55%>
        <input type=text wicket:id="pensionfraction"/>
    </td>
</tr>
<tr>
    <td colspan="2">
        <b>&nbsp;&nbsp;&nbsp;#8. Disturbing authority from which pension is to be drawn after retirement</b>
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;#8(a).Treasury/Sub-Treasury (Name and complete address of the Treasury/Sub-Treasury to be indicated)</b>
    </td>
    <td width=55%>
        <textarea wicket:id="treasurynameandaddress" rows='2' cols='50' class='normal' name='treasurynameandaddress'></textarea>
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;#8(b.i).Branch of the nominated nationalised bank with complete postal address</b>
    </td>
    <td width=55%>
        <textarea wicket:id="banknameandaddress" rows='2' cols='50' class='normal' name='BankNameandAddress'></textarea>
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;#8(b.ii).Bank Account No. to which monthly pension is to be credited each month.</b>
    </td>
    <td width=55%>
        <input type=text wicket:id="BankAccountNo"/>
    </td>
</tr>
<tr>
    <td width=45%>
        <b>&nbsp;&nbsp;&nbsp;(c).Account Office of the Ministry/Department/Office</b>
    </td>
    <td width=55%>
        <textarea wicket:id="accountoffice" rows='2' cols='50' class='normal' name='AccountOffice'></textarea>
    </td>
</tr>
<tr>
    <td width=45%>
        <b>Place:-</b>
            <input type=text wicket:id="place"/>
    <br>
        <b>Date:-</b>
            <input type="text" wicket:id="quoteDate">
    </td>
    <td width=45%>
        <b>Signature:-</b>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
    <br>
        <b>Present Postal address</b>
    <br>
        <textarea wicket:id="presentpostaladdress" rows='2' cols='50' class=normal name='PresentPostalAddress'></textarea>
    <br>
        <b>Postal Address after retirement</b>
    <br>
        <textarea wicket:id="addressafterretirement" rows='2' cols='50' class=normal name=AddressAfterRetirement></textarea>
    </td>
</tr> 

<tr bgcolor="#0e1f5b" height=30>
    <th colspan=4>
        <input type=submit name=Frm5iSave value=Save> 
        &nbsp;&nbsp;&nbsp;&nbsp; 
        <input type=submit name=Frm5iPrint value=Print>
    </th>
</tr>

</table>
</form>
</body>
</html>
View Answers









Related Pages:
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 multiple drop down list data in single column in sql database using servlet
How to insert multiple drop down list data in single column in sql database using servlet  i want to insert date of birth of user by using separate drop down list box for year,month and day into dateofbirth column in sql server
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
Drop Down
Drop Down  How to insert date into database using dropdown like facebook
dynamic drop down list box - Java Beginners
dynamic drop down list box  hi all , I want to dynamically populate a drop down box from an sql query in a servlet program, using only html... servlet comes under server side code. if not using servlet store the all data
view data from database using drop down list
view data from database using drop down list  hi i want to view the data from database by selecting a value in a drop down list. for an example drop down list have picture element.when click it select pictures from the database
how to import values from database to the drop down box
how to import values from database to the drop down box   hi iam... employee page i kept a drop down box for employee Ids i want all employee IDs will display in the drop down box please help me with the code
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 java  hi., i just need to correct my codes.somebody help me to clear... database: import java.sql.*; import java.awt.*; import javax.swing.*; import
dependent drop down box - JSP-Servlet
dependent drop down box  haloo sir Please give me the solution how to extract data from dependent drop down box with page refresh..., we have used following database tables: 1)book CREATE TABLE `book
store values of drop down list box in database
store values of drop down list box in database  how to store values of drop down list box in oracle database in jsp?I have information inserting form where i have date of birth as drop down list box
Login With Drop Down
using the drop down box and the Username and passwords must match with the Database...Login With Drop Down   Hi all, I am doing a project using JSP. My... box and then login to the page. I have a drop down list box with Customs
drop down box - JSP-Servlet
drop down box  when i enter some letter in the input box,the corresponding words of that particular letter must be displayed below as a list from the data base in the same input box as drop down. Thanks&Regards, VijayaBabu.M
drop down
drop down  how can i add data from choice/dropdown component of java awt to myaql table
Ajax drop down and textbox
Ajax drop down and textbox  hie frnds I have a dropdown menu in the 3 options(1,2,3) are there if i choose 1 then I should get 1 text box if i select...;And one more thing how to insert to the database dynamically
Get values in drop down list
in drop down box in front end..... pls provide me code.. thanx...Get values in drop down list  Pls provide me jsp code to get values in drop down list from another table's field. my project has customer
Drop Down reload in IE
Drop Down reload in IE  Hi i was using two drop down box..One for Displaying date followed by another for Dispalying Month..If i Select/Change Month from the 2nd drop down then the 1st drop down ( which is date) automatically
Drop Down Box
Drop Down Box  In a Drop Down box I want to show the user All the Country In the World. And when he type A-z,then each of the type Show those country which start with those word. Like I For-India
creation of drop down menu using ajax in java - Ajax
creation of drop down menu using ajax in java  Hi, Here I want to create a drop down menu using ajax in ofbiz framework. I want to fetch the data from database.I got examples using asp.net and php but I am not getting
Login With Drop Down, Having Departments in different table
using the drop down box and the Username and passwords must match... is to select the department from the drop down box and then login to the page. I have a drop down list box with Customs and Accounts..A Username and a Password
want to insert values in drop down menu in struts1.3
want to insert values in drop down menu in struts1.3  I am using DynaValidatorForm.please help me with inserting values in color drop down menu. I have tried belowwith arraylist but was not able to find solution. add.jspx
database is connected but not insert the data
database is connected but not insert the data  hi, i am getting connected to database.Retrive the data also but cannot insert the data into database. i am using msaccess2007.my inserstudententry.jsp code is follows,pls help me
Dependent drop down list
Dependent drop down list  hi,i am trying to design a form on which 2 dependent drop down list is used my code is successful but when i select class from first drop down list all the data get lossed means the value entered
jsp code for a drop down box to retrive value from database
jsp code for a drop down box to retrive value from database  my project needs to get the value from database in to the drop down box..... pls give me code for that ..... tan q   1)login.jsp: <html> <script>
JDBC: Drop Database Example
JDBC: Drop Database Example In this section, we are using JDBC API to drop database and describing it with example. Drop Database : Database... to the database, using jdbc API. Write query of drop database and call executeUpdate(sql
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java struts 1.3  hii, i am coding a form where i need a keyskills attribute... is displaying.. i need code in java so that it takes multiple values
data should not repeat in the drop down list when it is loading dynamically from database
data should not repeat in the drop down list when it is loading dynamically... the data dynamically for database but my problem is in the list the same...); } %> Data base tables are dept CREATE TABLE `dept
Dependant & dynamic drop down list
Dependant & dynamic drop down list  I don't know this should be in this or AJAX forum. I have one dynamic drop down list from data base (working... on the values selected by user in first drop down list. How to achieve this ?   
drop down menu
drop down menu  drop down menu using html
jsp login code ... when username , drop down box and password is correct
value is correct.... the drop down box values should be retrieved from database...jsp login code ... when username , drop down box and password is correct ....... the value is retrieved from database into combo box..... but the validation
jsp drop down-- select Option
jsp drop down-- select Option  how to get drop down populated...) in database and try the following code: <%@page import="java.sql.*"%> <html>...;/body> </html> 2)city.jsp: <%@page language="java" import
JSP Dependent Drop Down Menu
JSP Dependent Drop Down Menu  Hey Guy/Gals! I need someone help to guide me in creating a drop down menu, where the first menu affects the second menu and it's selection. So in my database I have a category table that has a ID
how to make drop down list in JSF & fetch data Item from database
how to make drop down list in JSF & fetch data Item from database  how to make drop down list in JSF & fetch data Item from database
how to retrieve the id value itself from the access database to drop down listbox in jsp
access database to drop down list box in jsp...plz send the code for that.....plz...how to retrieve the id value itself from the access database to drop down... data"); while(rs.next()){ int id=rs.getInt("id"); %> <option value
Insert data in mysql database through jsp using prepared statement
Insert data in mysql database through jsp using prepared statement...; This is detailed jsp code that how to insert data into database by using prepared statement...; <HEAD> <TITLE>insert data using prepared statement </TITLE>
Select functionality of drop down list - Struts
have Drop down list having element Test1,Test2,Test3,HIDE and one Text msg box...Select functionality of drop down list  Hi, I have to write a code(in struts application) in which if user select HIDE from the drop down list
how to retreive data dynamically from mysql to drop down list
how to retreive data dynamically from mysql to drop down list   sir... fron end using jsp , after storing the data successfully .i want to retrieve the data of a particular column in a table into drop down list dynamically
Drop Box
Drop Box  program draw 2d shapes in java
Drop Box
Drop Box  program draw 2d shapes in java
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
insert data in the database using checkbox
insert data in the database using checkbox  i am fetching data from the database using servlet on the jsp page and there is checkbox corresponding... should i insert only checked data into database on submission.   We
insert data into database
insert data into database  hi,thanks for reply just i am doing... and studentmaster is the database table name. i am using same details. Now give the data into the jsp page that data stored into the database.Here the error
Data needs to be gathered in XML file from the database (MySql) using JSP
Data needs to be gathered in XML file from the database (MySql) using JSP ... buttons and search text box or drop down box with search button,,, to display all... in XML file from the database (MySql) using appropriate JSP/Java Bean functions
Use of Select Box to show the data from database
Use of Select Box to show the data from database       Example program using Select Box to show retrieved data... page to show the data fetched from the database. We are using Servlet to get data
Drop-down text selection in jsp/html
Drop-down text selection in jsp/html  Hi, I am trying to create JSP page where I have two drop-downs. There are two-sets of data - First set.... Now the first dropdown will have all the values. The second drop-down depends upon
How to send the data selected from drop down menu from html page to sql 2005 database.
How to send the data selected from drop down menu from html page to sql 2005... by user from html drop down menu such as check-in date for hotel reservation system ,how can I save these data in database and how to retrieve later .Thanks
Dynamic Dropdown Menu
records from your database in a drop down menu/list box. You can apply... a table in your desired database,  you can create and insert values using...;head> <title>Dynamic Drop Down List</title> </head> <
Drop down list from database
Drop down list from database  Hi, Can I know how do we get the drop down list from database? Eg: select country--select state--select district--so..., we have created two database tables: CREATE TABLE `country

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.