Retriev values from database and display in a ComboBox

hi all,
i think the subject explains it all. how? currently iam using vectors which is giving me lots of problems and errors, whenever it adds to the combobox it adds the square braces as well example if the value in database is asrar then it will display [asrar], what is causing that? does anybody now any easier way??
asrar

please can someone help me
asrar

Similar Messages

  • How to get Date value from database and display them in a drop down list?

    Hello.
    In my Customers table, I have a column with Date data type. I want to create a form in JSP, where visitors can filter Customers list by year and month.
    All I know is this piece of SQL that is convert the date to the dd-mm-yyyy format:
    SELECT TO_CHAR(reg_date,'dd-mm-yyyy') from CustomersAny ideas of how this filtering possible? In my effort not to sound like a newbie wanting to be spoonfed, you can provide me link to external notes and resources, I'll really appreciate it.
    Thanks,
    Rightbrainer.

    Hi
    What part is your biggest problem?? I am not experienced in getting data out of a database, but the way to get a variable amount of data to show in a drop down menu, i have just messed around with for some time and heres how i solved it... In my app, what i needed was, a initial empty drop down list, and then using input from a text-field, users could add elements to a Vector that was passed to a JComboBox. Heres how.
    package jcombobox;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.swing.*;
    public class Main extends JApplet implements ActionListener {
        private Vector<SomeClass> list = new Vector<SomeClass>();
        private JComboBox dropDownList = new JComboBox(list);
        private JButton addButton = new JButton("add");
        private JButton remove = new JButton("remove");
        private JTextField input = new JTextField(10);
        private JPanel buttons = new JPanel();
        public Main() {
            addButton.addActionListener(this);
            remove.addActionListener(this);
            input.addActionListener(this);
            buttons.setLayout(new FlowLayout());
            buttons.add(addButton);
            buttons.add(remove);
            add(dropDownList, "North");
            add(input, "Center");
            add(buttons, "South");
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == addButton) {
                list.addElement(new SomeClass(input.getText()));
                input.setText("");
            } else if (e.getSource() == remove) {
                int selected = dropDownList.getSelectedIndex();
                dropDownList.removeItemAt(selected);
        public void init(String[] args) {
            setSize(400,300);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(new Main());
    }And that "SomeClass" is show here
    package jcombobox;
    public class SomeClass {
        private String text;
        public SomeClass(String input) {
            text = input;
        public String toString() {
            return text;
    }One of the things i struggled a lot with was to get the dropdown menu to show some usefull result. If the list just contains class references it will show the memory code that points to that class. Thats where the toString cones in handy. But it took me some time to figure that one out, a laugh here is welcome as it should have been obvious :-)
    When the app is as simple as this one, using a <String> vector would have been easier, but this is just to demonstrate how to place classes in a vector and get some usefull info out of it, hope this answered some of your question :-)
    The layout might have been easier to write, than using the toppanel created by the JApplet and then the two additional JPanels, but it was just a small app brewed together in 15 minutes. Please comments on my faults, so that i can learn of it.
    If you need any of the code specified more, please let me know. Ill be glad to,

  • Retrieving values from Database in Excel Task Pane App

    So far,
    I created a website with a database on Azure, I then published my App to Azure. My problem is that I'm not sure how I retrieve values from the database (in SQL: SELECT * FROM EXAMPLE_TABLE WHERE date = str). If someone could provide me with sample code,
    that would be amazing! :D
    It would also be very helpful if anyone knew a method to automatically update the database using information from a xml stream on another website, once a day.
    Thank you!

    Hi,
    >> My problem is that I'm not sure how I retrieve values from the database
    You can use jquery ajax call to call your webserivce or REST API, which will query the database and return a json result.
    Sample:
    Apps for Office: Create a web service using the ASP.NET Web API
    >> It would also be very helpful if anyone knew a method to automatically update the database using information from a xml stream on another website
    For the database sync-up question, I suggest you posting them on the forums like SQL Server Forum.
    Thanks for your understanding.
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Problem in Retrieve Image from DB and display in the JSP page

    Hi All,
    I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
    Database Used : MS Access
    DSN Name : image
    Table Name: image
    Image Format: bmp
    Output : 1973956
    Sample Program:_
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*" %>
    <%
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection conn = DriverManager.getConnection("jdbc:odbc:image");
              Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery("SELECT images FROM image");
              String imgLen="";
              if(rs.next()){
                   imgLen = rs.getString(1);
                   out.println(imgLen.length());
              if(rs.next()){
                   int len = imgLen.length();
                   byte [] rb = new byte[len];
                   InputStream readImg = rs.getBinaryStream(1);
                   int index=readImg.read(rb, 0, len);
                   System.out.println("index"+index);
                   st.close();
                   response.reset();
                   response.setContentType("image/jpg");
                   response.getOutputStream().write(rb,0,len);
                   response.getOutputStream().flush();
         }catch(Exception ee){
              out.println(ee);
    %>
    Thanks,
    Senthilkumar S

    vishruta wrote:
    <%
    %>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
                   out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
                   byte [] rb = new byte[len];Memory hogging. Don't do that.
              out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
    You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • Dynamically fetch data from database and display it in the report

    Hi,
    We have a requirement in developing a report which needs us to dynamically fetch data from the database and display it in the report.
    We have a column called WORKER in the report.
    For each worker there is a measure(PSA) associated with it.
    In the report we have to display both the WORKER and the PSA column.
    What we want is, when we display the list of the workers, the corresponding workerid_id of the worker will be passed and the value of his PSA will be fetched from the database and displayed in the report.
    Or anything similar to this.
    We also have drill applied on this WORKER column. So after any drill up or drill down also the value for PSA should change.
    Is there any way of doing this?
    Please help if possible.
    Thanks,

    hi,
    data : count type i value 0.
    data : Begin of itab occurs 0 ,
    plan_version like hrhap-plan_version,
    APPRAISAL_ID like hrhap-APPRAISAL_ID,
    AP_START_DATE like hrhap-AP_START_DATE,
    AP_END_DATE like hrhap-AP_END_DATE,
    AP_STATUS like hrhap-AP_STATUS,
    AP_STATUS_SUB like hrhap-AP_STATUS_SUB,
    OBJ_DATE_SET like hrhap-OBJ_DATE_SET,
    REVIEW_DATE_SET like hrhap-REVIEW_DATE_SET,
    AP_DATE_SET like hrhap-AP_DATE_SET,
    AP_DATE_EARLIEST like hrhap-AP_DATE_EARLIEST,
    AP_DATE_LATEST like hrhap-AP_DATE_LATEST,
    CHANGE_DATE like hrhap-CHANGE_DATE,
    CHANGE_TIME like hrhap-CHANGE_TIME,
    CHANGE_USER like hrhap-CHANGE_USER,
    end of itab.
    <b>select * from hrhap into corresponding fields of table itab.</b>
    loop at itab.
    write :/ itab-plan_version under 'plan_version',
    itab-appraisal_id under 'Appraisal Id',
    itab-AP_START_DATE under 'Start Date',
    itab-AP_END_DATE under 'End date',
    itab-AP_STATUS under 'Status',
    itab-AP_STATUS_SUB under 'Substatus',
    itab-OBJ_DATE_SET under 'Objective setting date',
    itab-REVIEW_DATE_SET under 'Review date set',
    itab-AP_DATE_SET under 'appraisal date',
    itab-AP_DATE_EARLIEST under 'Earliest appraisal date',
    itab-AP_DATE_LATEST under 'Latest Appraisal date',
    itab-CHANGE_DATE under 'Change Date',
    itab-CHANGE_TIME under 'change time',
    itab-CHANGE_user under 'change user'.
    count = count + 1.
    endloop.
    write : 'No of records' ,count.
    rgds
    anver
    if hlped mark points.

  • How to display checkbox that retrieve value from database?

    Hi,
    I have a problem, hope someone will help me.
    The problem is, I have 3 checkbox where contain different values.
    I will insert the values to db in array. When I retrieve the values, I got a problem to display it.
    Let say,my checkbox's value is:
    1.car
    2.bus
    3.lorry
    when I checked car and lorry, my array will be [car,bus] insert to db.
    For editing purpose, I need to display the checkbox again with the values from db. So, it should be :
    1.car (checked)
    2.bus (checked)
    3.lorry (unchecked)
    I can display the car and bus (checked) , but not the unchecked checkbox. Sometimes, it's repeating, car (checked) and car (unchecked) will display.
    Anybody have a suggestion?
    My codes:
    String[] list = {"car","bus","lorry"};
    String[] logtype ={"car","bus"}//retrieve from db (example)
    for (int i=0;i<logtype.length;i++){
    if (logtype.equals(list[i]){
    <input type="checkbox" name="type" value="<%=list[i]%>" checked>
    else{
    <input type="checkbox" name="type" value="<%=list[i]%>" >

    hey u can solve this problem by using vector instead of array
    here's the code
    <%
    Vector list=new Vector();
    list.addElement("car");
    list.addElement("bus");
    list.addElement("lorry");
    Vector logtype=new Vector();
    logtype.addElement("car");
    logtype.addElement("bus");
    for(int i=0;i<list.size();i++)
         if(logtype.contains(list.elementAt(i)))
         { %>
              <%=list.elementAt(i)%><input type="checkbox" name="type" value="<%=list.elementAt(i)%>" checked>
         <%}
         else
         {%>
              <%=list.elementAt(i)%><input type="checkbox" name="type" value="<%=list.elementAt(i)%>" >
         <%}
    %>

  • ADF: Retrieve values from view and autofill in JSP

    Hi,
    I am using jdev 10.1.3 with ADF.
    I have a jsp page, on which I have 10 fields. On filling one particular field, the other related fields should be retreived from a Synonym or view (That I have in my database.) and automatically filled in jsp page.
    If I am not clear, I have a jsp page which has account number, bill to and ship to fields.
    There is a Synonym table which has the account number, billto and ship to fields. when I fill in the account number field in my jsp, then it should be validated against the synonym and retrive the bill to and ship to information for that particular account number and displayed automatically in the JSP.
    Can you give me any examples or URLs please?
    Thanks,
    Priya

    Hi
    I hope you can solve your problem with one of following solutions.
    1. Return the resultset to jsp program.
    In this getrow() method in Viewtable.java will look like this
    public void getrow() throws SQLException,IOException {
    System.out.println("see what happen" );
    String query = "SELECT PRODID,QUANTITY FROM INVENTORY";
    st = con.createStatement();
    rs = st.executeQuery(query);
    return rs;
    and your jsp program will be....
    <% ResultSet rs = view.getrow();
    while (rs.next()) {
    qty = rs.getString("QUANTITY");
    id = rs.getString("PRODID");
    System.out.println(qty + " " );
    %>
    2. If you just want to print the details then pass the "out"
    variable to getrow() method. ex:view.getrow(out)
    3. Otherwise store all your values in an array and return it.
    bye
    Sridhar

  • Read integer values from spreadsheet and display the values in a table

    Hi all,
    I have integer values to read from a spreadsheet and display them in a table. I am using 'Read from spreadsheet file' in 'integer' mode. I would like to display these values in a table. The problem is that the table takes only 2d-array of string as input but not integer.  
    It works fine if I change the mode of 'Read from spreadsheet file' from 'integer' to 'string' but I want to read integers and have to use the integer values for further calculations. Please give any suggestions on displaying integers to a table.
    Thank you. 
    Solved!
    Go to Solution.

    No don't take element by element just convert as a whole. See the attached example
    Good luck
    The best solution is the one you find it by yourself

  • DO Web Service allow you to retrieve data from database and make it pluggab

    Can Web Services allo you to retrieve data from the database and do they make the pluggable by allow you to plug them into any database.. how is that possible....

    Going through the javaee tutorial is one sure way of accelerating your learning curve, as almost every basic you will need to get your job done is explaiined well in there. i have been using it to learn building enterprise application and is awesome good resource.
    seriously consider downloading it
    java.sun.com/javaee/5/docs/tutorial/doc/

  • Retrieve URL from database and navigate through command button

    I am new to ADF and Jdeveloper. In our database we store the URLs to our help/FAQ webpage in a table. What I would like to do is retrieve this URL from the database and code a command button to navigate the user to this URL but I am not sure how to accomplish this and have not had any lucking searching for a solution. I have created a view object for the table that contains the URL. Many thanks in advance.

    Hi,
    Welcome to OTN.
    You can create a view object based on the table (on which you have the URL stored).
    Create a goButton (Instead of a command button) and bind the column (which stores the URL) to the destination property of the go button.
    Something like
    <af:goButton text="Help" id="gb1"
                        targetFrame="_blank" destination="#{bindings.URL.inputValue}"/>-Arun

  • How to sort data from database and display in combobox in required order

    Hi evrybody, it makes me sick i need to get data form database and fill combobox in required order (last item added to database - last firstName) actualy i already did that, but i'm useing DefaultComboBoxModel and all records are sorted in alphabetical order. Thanks very much for any help

    The items in the JComboBox are displayed in the order in which you add them to the combo box. Use an order by clause in your SQL statement.
    Don't [url http://forum.java.sun.com/thread.jsp?forum=54&thread=516608]crosspost.

  • Want to retrieve values from TB028 and TB009

    Hi Experts ,
    I wanted to retrieve value of TB028-BEZ30 ( Description for occupation) depending upon field JOBGR in BUT000 , similarly in Table  TB009-TEXTSHORT(Short name for Address type) wanted to get the value depeding upon ADR_KIND in BUT021.
    But I am not able to retriev this value. I tried using some FMs too but they dont return either of these fields in their o/p parameters
    FM used :
    For retriving TB028 fields
                BAPI_BUPA_CENTRAL_GETDETAIL
    For retiving TB009 fields :
              FSBP_READ_ADDRESS_DATA
              BUP_TB009_SELECT_ALL
              BUPA_ADDRESSES_READ_ALL
    None of these returns the fields I want. Am I missing something here??
    Regards,
    Neel

    Hello Anitha,
    Since u have declared it as global variable there is no need to declare inside the routine.
    If useful award the points.
    Regards,
    Vasanth

  • Retrieve values from database

    Hi,
    one of the search form contains the select option for country , state and
    distributor type.
    the country drop down has 2 values - US and canada
    the conditions needed to be satisfied are :
    (1) if the country selected is US - then the states dropdown should only show the states that are associated with US in the table in the database(TABLE name is - "distributors")
    and if country selected is Canada - then should show states in canada only
    (2) if canada is selected in the country dropdown, the distributor type which has 2 values - stationary and automotive - should show only the stationary in the dropdown and not show the automotive
    This is done with the LocateQueryServlet.java...can someone please tell me how this needs to be updates so that the above conditions are satisfied...
    Attaching the code from LocateQueryServlet.java and the prolog.sql
    --------------------------------------------------------------------------------------------------LocateQueryServlet.java
    package com.dupont.refrigerants.distributorlocator;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.ejb.CreateException;
    import javax.naming.NamingException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.proxicom.util.MiscEJBFunctions;
    * This servlet displays a query form for locating distributors. It relies on
    * the 'countries', 'states' and 'types' tables in the database to fill its
    * forms. If a table is empty, it doesn't display the corresponding select
    * (pulldown) widget. This only displays the form fragment of HTML, and should
    * be included in a complete page, probably with JSP or the like.
    * XXX Currently, the form is populated when the servlet is initialized, which
    * is a hack because I don't remember the appropriate j2ee idiom.
    * @web.servlet name="queryServlet" display-name="Distributor Locator Query
    * Servlet" description="Servlet that gets a query form for finding
    * distributors in a given region"
    * @web.servlet-mapping url-pattern="/queryServlet"
    public class LocateQueryServlet extends HttpServlet {
         * Abstract class for converting a java object into
         * an option element for an HTML select form widget.
         private abstract static class Object2Option {
              * Gets the default option at the top of the select.
              * To have no default, override this to return the
              * empty string.
              * @return <code>>option selected='true' value=''<-- Select One -->/option<</code>
              public String getDefault() {
                   return "<option selected='true' value=''>-- Select One --</option>";
              * The option element that represents the given info object.
              * @param o the info object
              * @return an unselected HTML option element.
              abstract public String getOptionFor(Object o);
              * Helper method for generating a select option element
              * with the given un-encoded value and text.
              * @param value
              * unencoded string to be passed as the form
              * value when selected
              * @param text
              * unencoded string to be displayed in the select
              * box pulldown
              * @return the concatenated and appropriately escaped
              * option element
              protected static String getOptionWith(String value, String text) {
                   return "<option value='" + Utilities.webify(value, false) + "'>"
                             + Utilities.webify(text, false) + "</option>";
         * Function object for generating 'Country' select box items.
         private static class Object2CountryOption extends Object2Option {
              * Converts a CountryInformation object into an appropriate
              * HTML option element.
              public String getOptionFor(Object o) {
                   CountryInformation c = (CountryInformation) o;
                   return getOptionWith(c.getCode(), c.getName());
         * Function object for generating 'Distributor Type' select box items.
         private static class Object2DistributorTypeOption extends Object2Option {
              * Converts a DistributorTypeInformation object into an appropriate
              * HTML option element.
              public String getOptionFor(Object o) {
                   DistributorTypeInformation c = (DistributorTypeInformation) o;
                   return getOptionWith(String.valueOf(c.getId()), c.getDescription());
         * Function object for generating 'State/Province' select box items.
         private static class Object2StateOption extends Object2Option {
              * Converts a StateInformation object into an appropriate
              * HTML option element.
              public String getOptionFor(Object o) {
                   StateInformation c = (StateInformation) o;
                   return getOptionWith(c.getCode(), c.getName());
         private String countries;
         private String states;
         private String types;
         * Constructs a simple locate query servlet.
         public LocateQueryServlet() {
              super();
         * Generates an HTML select form widget for the given list of values.
         * @param formName the name of the widget for the HTML name attribute
         * @param values the values to convert into a list
         * @param factory the method for converting each value into an option.
         * @return the complete 'select' element
         private String generateSelectFor(String formName, List values,
                   Object2Option factory) {
              StringBuffer sb = new StringBuffer();
              sb.append("<select name='").append(Utilities.webify(formName, false)).append("'>");
              sb.append(factory.getDefault());
              for (Iterator iter = values.iterator(); iter.hasNext();) {
                   sb.append(factory.getOptionFor(iter.next()));
              sb.append("</select>");
              return sb.toString();
         * Initializes the servlet. Actually results in some queries getting run.
         * @param config
         * @throws ServletException
         public void init(ServletConfig config) throws ServletException {
              try {
                   DistributorDBABeanHome distBean = (DistributorDBABeanHome) MiscEJBFunctions.getBeanHomeInterface(null, null, Utilities.EJB_DISTRIBUTOR_DBA_NAME);
                   DistributorDBABean dists = distBean.create();
                   this.countries = this.generateSelectFor("country", dists.getCountries(),
                             new Object2CountryOption());
                   this.states = this.generateSelectFor("state", dists.getStates(),
                             new Object2StateOption());
                   this.types = this.generateSelectFor("type", dists.getDistributorTypes(),
                             new Object2DistributorTypeOption());
              } catch (NamingException e) {
                   throw new ServletException("Lookup of "
                             + Utilities.EJB_DISTRIBUTOR_DBA_NAME + " failed", e);
              } catch (CreateException e) {
                   throw new ServletException(
                             "Error while creating distributor session bean", e);
              } catch (java.rmi.RemoteException e) {
                   throw new ServletException(
                             "Error while initializing distributor locator", e);
         * Executes the HTTP request and return the appropriate HTML form fragment.
         * @param request
         * @param response
         * @throws ServletException
         * @throws IOException
         protected void doGet(HttpServletRequest request,
                   HttpServletResponse response) throws ServletException, IOException {
              PrintWriter out = response.getWriter();
              response.setContentType("text/html");
              String action = request.getParameter("action");
              if (action == null) {
                   action = "where-to-buy-results";
              } else {
                   action = Utilities.webify(action, false);
              // Open form and table elements.
              out.println("<form id='distributorLocator' action='" + action + "' method='get'>"
                                  + "<table width='100%' border='0' cellpadding='4' cellspacing='0'>");
              // buffer row
              //out.println("<tr><td colspan='2'><hr width='65%' size='1' noshade></td></tr>");
              // 'Country' row
              out.println("<tr><td><div align='right' class='formSubHead'>Country:</div></td>"
                                  + "<td>" + this.countries + "</td></tr>");
              // 'States' row
              out.println("<tr><td><div align='right' class='formSubHead'>State/Province:</div></td>"
                                  + "<td>" + this.states + "</td></tr>");
              // 'Application' row
              out.println("<tr><td><div align='right' class='formSubHead'>Application:</div></td>");
              out.println("<td>" + this.types + "</td></tr>");
              // or row
              out.println("<tr><td><div align='right'></div></td><td><em><strong>or</strong></em></td></tr>");
              // zip code row
              out.println("<tr><td><div align='right' class='formSubHead'>Zip Code/Postal Code: </div></td>"
                                  + "<td><input id='zip' name='zip' type='text' /></td></tr>");
              // buffer row
              out.println("<tr><td colspan='2'><hr width='65%' size='1' noshade></td></tr>");
              // submit row
              out.println("<tr><td> </td><td><input type='submit' value='Find' /></td></tr>");
              // end table and form
              out.println("</table></form>");
    prolog.sql
    SET DEFINE OFF;
    CREATE SEQUENCE distributor_id_seq START WITH 1 INCREMENT BY 1 NOMAXVALUE;
    CREATE TABLE countries (code CHAR(2), name VARCHAR(254),
         CONSTRAINT country_pk PRIMARY KEY(code));
    CREATE TABLE states (code CHAR(5), name VARCHAR(254), country CHAR(2),
         CONSTRAINT state_pk PRIMARY KEY(code),
         CONSTRAINT fk_country FOREIGN KEY(country) REFERENCES countries(code));
    CREATE TABLE distributorTypes (id INTEGER, name VARCHAR(254),
         CONSTRAINT distributorType_pk PRIMARY KEY(id));
    CREATE TABLE distributors
         (id INTEGER,
         name VARCHAR(254),
         zip VARCHAR(12),
         country CHAR(2),
         state CHAR(5),
         city VARCHAR(63),
         address1 VARCHAR(254),
         address2 VARCHAR(254),
         fax VARCHAR(32),
         phone VARCHAR(32),
         managers VARCHAR(254),
         type INTEGER,
         email VARCHAR(254),
         url VARCHAR(254),
         CONSTRAINT distributor_pk PRIMARY KEY(id),
         CONSTRAINT fk_dist_country FOREIGN KEY(country) REFERENCES countries(code),
         CONSTRAINT fk_dist_state FOREIGN KEY(state) REFERENCES states(code),
         CONSTRAINT fk_dist_type FOREIGN KEY(type) REFERENCES distributorTypes(id));
    CREATE TABLE statesApply (state CHAR(5), distributor INTEGER,
         CONSTRAINT fk_apply_state FOREIGN KEY(state) REFERENCES states(code),
         CONSTRAINT fk_apply_distributor FOREIGN KEY(distributor) REFERENCES distributors(id));
    INSERT INTO
              distributorTypes (id, name) VALUES (1, 'Air Conditioning - Stationary and Refrigeration');
    INSERT INTO
              distributorTypes (id, name) VALUES (2, 'Air Conditioning - Automotive');
    INSERT INTO
              countries (code, name) VALUES ('CA', 'Canada');
    INSERT INTO
              countries (code, name) VALUES ('US', 'United States of America');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AL', 'Alabama');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_KS', 'Kansas');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_ND', 'North Dakota');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AK', 'Alaska');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_KY', 'Kentucky');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MP', 'N. Mariana Islands');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AS', 'American Samoa');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_LA', 'Louisiana');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_OH', 'Ohio');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AZ', 'Arizona');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_ME', 'Maine');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_OK', 'Oklahoma');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AR', 'Arkansas');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MH', 'Marshall Islands');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_OR', 'Oregon');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_CA', 'California');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MD', 'Maryland');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_PW', 'Palau');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_CO', 'Colorado');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MA', 'Massachusetts');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_PA', 'Pennsylvania');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_CT', 'Connecticut');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MI', 'Michigan');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_PR', 'Puerto Rico');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_DE', 'Deleware');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MN', 'Minnesota');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_RI', 'Rhode Island');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_DC', 'District of Columbia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MS', 'Mississippi');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_SC', 'South Carolina');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_FM', 'FS Micronesia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MO', 'Missouri');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_SD', 'South Dakota');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_FL', 'Florida');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MT', 'Montana');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_TN', 'Tennessee');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_GA', 'Georgia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NE', 'Nebraska');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_TX', 'Texas');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_GU', 'Guam');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NV', 'Nevada');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_UT', 'Utah');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_HI', 'Hawaii');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NH', 'New Hampshire');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_VT', 'Vermont');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_ID', 'Idaho');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NJ', 'New Jersey');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_VI', 'Virgin Islands');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_IL', 'Illinois');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NM', 'New Mexico');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_VA', 'Virginia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_IN', 'Indiana');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NY', 'New York');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WA', 'Washington');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_IA', 'Iowa');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NC', 'North Carolina');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WV', 'West Virginia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WI', 'Wisconsin');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WY', 'Wyoming');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_AB', 'Alberta');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_BC', 'British Columbia');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_MB', 'Manitoba');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NB', 'New Brunswick');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NL', 'Newfoundland and Labrador');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NS', 'Nova Scotia');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NT', 'Northwest Territories');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NU', 'Nunavut');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_ON', 'Ontario');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_PE', 'Prince Edward Island');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_QC', 'Qu�bec');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_SK', 'Saskatchewan');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_YT', 'Yukon');
    Any immediate help is truly appreciated.
    Thanks in advance

    I thank you for the link, it's something I've already done several times ....
    actually this code tries to manage a key incremental, I am obliged to do that because I am in MS SQL Server and therefore what works for oracle does not work for SQL Server, which is why I want to do it manual, I also posted this in a previous post and I was asked to retrieve the field value by Code: Help please : dbsequence refresh on MS sql server
    now admitting that it is not what I want to do and I have the following code:
    if (it1.getValue () == null) (
    Connection connection = ConnectionManager.getInstance (). GetConnection ();
    Statement statement = connection.createStatement ();
    ResultSet resultset = statement.executeQuery ("SELECT id FROM WHERE name = spider" it2.getValue + () + "");
    while (resultSet.next ())
    it1.setValue (resultSet.getInt (1));
    BindingContainer getBindings bindings = ();
    OperationBinding operationBinding bindings.getOperationBinding = ("Commit");
    OperationBinding.execute Object result = ();
    if (! operationBinding.getErrors (). isEmpty ()) (
    return null;
    else (
    BindingContainer bindings2 getBindings = ();
    OperationBinding operationBinding2 bindings2.getOperationBinding = ("Commit");
    OperationBinding2.execute Object result = ();
    if (! operationBinding2.getErrors (). isEmpty ()) (
    return null;
    What code ADF BC I will put in place of jdbc code

  • How to retrieve datas from database to dropdown list in jsp

    hai.
    please tell me how to retrieve a perticular field list from database to a drop down list using jsp. i am new to jsp. i am doing employee management system. in that i need to edit employee's details as like.
    so that i want to display employee id's in a drop down list. i want to retrieve from database and display.
    please help me in this .
    advance thanks.

    Hello friendz,
    If tht is the i wud suggest if guyz can go wid AJAX...
    try to make use of xmlHttp Object and generate a new dependent drop down by using a property from a bean->servlet->VIEW(FORM)
    else save the form state in a session and then refersh it. once all in again.
    i had a similar problem which i solved in the following way
    Hi friend,
    I had a similar situation and i tried to solve it by using XmlHttpRequest Object(used in AJAX).
    U can checkout the below example just for further reference delete
    UserForm.jsp:
    ==========
    <head>
    <script>
    var xmlHttp
    function showState(str)
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    alert ("Browser does not support HTTP Request")
    return
    var url="getState.jsp"
    url=url+"?count="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChange
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    function stateChange()
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById("state").innerHTML=xmlHttp.responseText
    </head>
    <body>
    <select name='country' onchange="showState(this.value)">
    <option value='india>india</option>
    </select>
    <br>
    <div id='state'>
    <select name='state' >
    <option value='-1'>pickone</option>
    </select>
    </div>
    </body>       
    getState.jsp
    ============
    <%@page language="java" import ="java.util.Hashtable" import ="java.util.Set" %>
    <%
    String country=request.getParameter("count");
    response.setContentType("text/html");
    response.setHeader("Cache-Control","no-cache");
    try{
    Hashtable ht = (Hashtable)session.getAttribute("<ATTRIBUTE_NAME>");
    String buffer="<select name='state'><option value='-1'>Pick One</option>";
    Set s=ht.keySet();
    Object keys[]=s.toArray();
    int size=keys.length;
    for(int i=0; i < size;i++){
    buffer=buffer+"<option value='"+ht.get(keys).toString()+"'>"+ht.get(keys).toString()+"</option>";
    buffer=buffer+"</select>";
    response.getWriter().println(buffer);
    catch(Exception exp){
    response.getWriter().println(exp);
    %>

  • Problem in retreiving from database and viewing it in browser--urgent

    hai,
    i have develped an application using swings where the mails received from client and reply posted will be pasted in JEditorPane. all the mails,query and reply will be stored in database.
    then iam retrieving the mails from database and displaying it in browser using table data.(Just like forum). Iam using encodehtmltag function to omit the html tags that r present in the mail data.
    when i display it in browser it extends a page horizontically. how to avoid this. how to word wrap. one of my friend asked me to set number of character to be displayed per line. i did that. but problem is i could see the word break . i have set 90 characters to be displayed per line. i dont want to break the word. for eg., if the end string of a line is regarding it is displayed like this---reg and then arding in next line. how to avoid this.
    please help me iam breaking my head with this for past few days.

    If the field is a Date in your database, you can use the ResultSet.getDate() method, which will return a java.sql.Date (which extends java.util.Date).
    You can then use SimpleDateFormat to format it the way you like.
    See the API doc for more details.

Maybe you are looking for

  • How to create a single view like report ?

    Hello, basic task is to present a user with 2 versions of the record from the DB. User then will decide either to "approve" the newer version or disregard the changes. I'm thinking of presenting these rows in a 2 single view report forms. how do i cr

  • Calculation using multiple select statements - APEX 4.0

    Hello, I am new to APEX, PL/SQL and have some SQL knowledge, but I pick up things quickly. I want to make a page item equal to the value of a Select statement minus another Select statement. The statements pull from the same tables and only differ sl

  • How to run a server program in the background on Linux or Windows?

    I just finished writing a Java network application with multiple clients and one server. However, I am not sure how I can run the server (SomeServer.class) in the background on Windows. Also when I am running it on Linux, I don't want it to terminate

  • Error 80080005 during windows update on Server 2008 R2 Datacenter

    I have tried MS fix it to no avail. I still can't install Windows update.  I did have problems with pofiles being corrupted and wonder if this is related, but I am stuck. What is the next step in trying to get Windows Update to work? Thanks ~Randy

  • Photoshop (CS3) Hangs When Started

    I just purchased PS CS3 and after spending an entire evening and morning getting to the point where the software asked for my serial number, I still have not gotten anything other than a PS window and an hourglass cursor with the window indicating th