HELP! Displaying results from a database in table format

I'm developing a web application that will use a considerable number of database queries that need to be displayed back to the web-browser in HTML table format.
I have been told that that result sets can allow tables to be built automatically without having to write the same loop and display code over and over.
So far I have a HtmlResultSet class as follows:
import java.sql.*;
public class HtmlResultSet {
private ResultSet rs;
public HtmlResultSet(ResultSet rs) {
this.rs = rs;
public String toString() {  // can be called at most once
StringBuffer out = new StringBuffer();
// Start a table to display the result set
out.append("<TABLE>\n");
try {
ResultSetMetaData rsmd = rs.getMetaData();
int numcols = rsmd.getColumnCount();
// Title the table with the result set's column labels
out.append("<TR>");
for (int i = 1; i <= numcols; i++) {
out.append("<TH>" + rsmd.getColumnLabel(i));
out.append("</TR>\n");
while(rs.next()) {
out.append("<TR>"); // start a new row
for (int i = 1; i <= numcols; i++) {
out.append("<TD>"); // start a new data element
Object obj = rs.getObject(i);
if (obj != null)
out.append(obj.toString());
else
out.append(" ");
out.append("</TR>\n");
// End the table
out.append("</TABLE>\n");
catch (SQLException e) {
out.append("</TABLE><H1>ERROR:</H1> " + e.getMessage() + "\n");
return out.toString();
I also have created a class that includes an instance of the class above to display the results, as follows:
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class customerLookup2 {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try{
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sandywalker");
out.println("<html>");
out.println("<head><title> Users</title></head>");
out.println("<body> Customers");
HtmlResultSet result = new HtmlResultSet ("SELECT * FROM USERS");
out.println("</body></html>");
catch(ClassNotFoundException e ) {
out.println("Couldn't load database driver: " + e.getMessage());
catch(SQLException e) {
out.println("SQLExeption caught: " +e.getMessage());
finally {
try {
if (con !=null) con.close();
catch (SQLException ignored) { }
I keep getting a compile error "customerLookup2.java": Error #: 300 : constructor HtmlResultSet(java.lang.String, java.sql.Connection) not found in class HtmlResultSet at line 42, column 34".
Can anyone shed any light on this.

Looks like you are passing a string (SELECT * FROM USERS) instead of passing a ResultSet. Try passing a Resultset.

Similar Messages

  • Trouble displaying results from a database call

    Hi Everyone,
    I have written a JSP page that sends and receives information to a MySQL database. It is not completely functional unfortunately. The first section of the page that is responsible for updating a database table works fine. However when I go to retrieve information from the same database table something is going astray.
    I feel that I am doing something wrong with regard to the ResultSet object. Please see the bottom of the code section below. Ultimately this code only displays beach_percent as Zero, no matter how many entries there are in the database table for the corresponding value of Beach & Sea Stamps.
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page import="java.sql.*" %>
    <%
         Connection connect = null;
         Statement state = null;
         ResultSet rs = null;
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         String password = "theOne";
         String url = "jdbc:mysql://localhost/survey_database";
         String user = "David";
         connect = DriverManager.getConnection(url, user, password);
         state = connect.createStatement();
         if(request.getParameter("radiobutton") != null)
              String enter_text = "insert into craft_survey values('";
              enter_text = enter_text.concat(request.getParameter("radiobutton"));
              enter_text = enter_text.concat("')");
              rs = state.executeQuery(enter_text);
         else
              pageContext.forward("craftSurvey.jsp");
         rs = state.executeQuery("SELECT stamp FROM craft_survey");
         int beach = 0;
         int bear = 0;
         int christmas = 0;
         int country = 0;
         int easter = 0;
         int faux = 0;
         int floral = 0;
         int heart = 0;
         int phrase = 0;
         int special = 0;
         int total = 0;
         while(rs.next())
              String type = rs.getString("stamp");
              if(type.equals("Beach & Sea Stamps"))
                   beach++;
                   total++;
              else
              if(type.equals("Bear & Cuddly Stamps"))
                   bear++;
                   total++;
              else
              if(type.equals("Christmas Stamps"))
                   christmas++;
                   total++;
              else
              if(type.equals("Country & Garden Stamps"))
                   country++;
                   total++;
              else
              if(type.equals("Easter Stamps"))
                   easter++;
                   total++;
              else
              if(type.equals("Faux Postage"))
                   faux++;
                   total++;
              else
              if(type.equals("Floral Stamps"))
                   floral++;
                   total++;
              else
              if(type.equals("Heart & Romance Stamps"))
                   heart++;
                   total++;
              else
              if(type.equals("Phrase & Wording Stamps"))
                   phrase++;
                   total++;
              else
              if(type.equals("Special Occasion Stamps"))
                   special++;
                   total++;
         int beach_percent = 0;
         int bear_percent = 0;
         int christmas_percent = 0;
         int country_percent = 0;
         int easter_percent = 0;
         int faux_percent = 0;
         int floral_percent = 0;
         int heart_percent = 0;
         int phrase_percent = 0;
         int special_percent = 0;
         if(beach > 0)
              beach_percent = (beach / total) * 100;
         if(bear > 0)
              bear_percent = (bear / total) * 100;
         if(christmas > 0)
              christmas_percent = (christmas / total) * 100;
         if(country > 0)
              country_percent = (country / total) * 100;
         if(easter > 0)
              easter_percent = (easter / total) * 100;
         if(faux > 0)
              faux_percent = (faux / total) * 100;
         if(floral > 0)
              floral_percent = (floral / total) * 100;
         if(heart > 0)
              heart_percent = (heart / total) * 100;
         if(phrase > 0)
              phrase_percent = (phrase / total) * 100;
         if(special > 0)
              special_percent = (special / total) * 100;
    %>
    <html>
    <head>
    <title> Craft Stamp Survey Results </title>
    </head>
    <body background="#ffffff">
    <h1> Craft Stamp Survey Results </h1>
    <table width="100%">
         <tr align="center">
         <td><img src="green_bar.jpg" height="20" width="<%=beach_percent *3%>"></td>
            <td>Beach & Sea Stamps</td>
            <td><%=beach_percent%></td>
    </tr>
    </table>
    </body>
    </html>Any help with getting this page to display anything other than zero will be great appreciated.
    Thanks
    David

    Hi,
    One reason could be of spaces .Before checking in the loop use trim function on the data retrieved from the database. You can also debug using System.out.println.
    Also just a suggestion - it is always a good coding practice to declare the variablse outside the loop. Don't declare the variables within a for loop.

  • Trying to display results from access database query on a JSP

    Seem to be having real difficulty with this one, i keep getting a null pointer exception :(. Wondered if anyone could point me to any examples of displaying the results on jsp. The database is connected, as i can display the query on netbeans, but just not on a jsp.

    I think it would be good if we had a section in these forums for pre-canned answers to the same questions that come up again and again. It would save time.
    Here is a rough outline for using JSP:
    * Read a JSP book.
    * The JSP page (View in MVC) should get all the data it needs to display from a useBean and/or request.getAttribute().
    * The JSP page should not have any business logic. Its purpose is to display data only (and have some submit buttons such as 'update').
    You can do some basic client side validation using javascript if you want. Because there is no business logic in it, you can easily debug
    your code in the servlet or business logic. You can't set breakpoints in JSP and examine data easily.
    * When you click the submit button, all data from <input type="text" tags, etc is put into request scope via name/value pairs.
    * Submit the JSP page <form tag to a servlet (Control in MVC).
    * The servlet reads the name/value pairs of data from the JSP page via request.getParameter()
    * The servlet should then instansiate a business object (Model in MVC), passing the data it got from the page to the business logic.
    Example: ProcessPage processPage();
    if(request.getParameter("updateButtonClicked"))
    processPage.updateData(data from the jsp page)
    * The business logic should instansiate a separate database object (DAO) to get data to/from the database. Business logic should not have sql in it.
    Business logic should not generate html. Business logic should not have request objects in it.
    * The business logic should return data to the servlet that in turn will put it in request scope via request.setAttribute() so the JSP page can draw itself.
    * The servlet should then call up the approprate JSP page.

  • Displaying results from a database query using servlets

    I have this HTML form where users can search a MS Access database by entering a combination of EmployeeID, First name or last name. This form invokes a Java Servlet which searches the database and displays the results as an HTML page. I am giving the user the choice of displaying 3, 5 or 10 results per page. I want to know how to do that using servlets. If a particular search results in 20 results, the results should be displayed in sets of 3, 5 or 10 depending on the user's choice. If the user makes a choice of 5 results per page then 4 pages should be displayed with a "next" and "previous" button on each page. I want to know how this can be done.

    Arun,
    I'm not sure how to do this using JSP as I have not worked on JSP.
    But I can give you a hint on how to do this within normal java class as I've used this in my current project.
    In your core class/bean that generates the entire resultset, you need to run a loop that will scan through the desired number of records in the resultset.
    To do this, you have to have skip and max parameter in your URL.
    Somthing like http://server.com/myservlet?skip=0&max=10 to display first 10 records, http://server.com/myservlet?skip=10&max=10 to display next 10 records. The <next>parameter would be fed in by the user by a simple form in your web-page. If you need to hold this <max-num-of-recs-per-page> param, you can store it in a cookie (since this is nothing crucial piece of info, don't need to use session obj etc...cookie will do) and get the value each time you display the resultset.
    So, essentially, suppose you are at the first page and you wish to show 10 recs at a time. The link for "Next" button would be http://server.com/myservlet?skip=10&max=10
    when at the second page, you'll have
    "priv" button as http://server.com/myservlet?skip=0&max=10 and
    "next" button as http://server.com/myservlet?skip=20&max=10 and so on...
    hope this makes sense..
    Shantanu

  • Walkthrough: Displaying Data from Oracle database in a Windows application.

    This article is intended to illustrate one of the most common business scenarios such as displaying data from Oracle database on a form in a Windows application using DataSet objects and .NET Framework Data Provider for Oracle.
    You can read more at http://www.c-sharpcorner.com/UploadFile/john_charles/WalkthroughDisplayingDataOracleWindowsapplication05242007142059PM/WalkthroughDisplayingDataOracleWindowsapplication.aspx
    Enjoy my article.

    hi,
    this is the code :
    public class TableBean {
    Connection con ;
    Statement ps;
    ResultSet rs;
    private List perInfoAll = new ArrayList();
    public List getperInfoAll() {
    int i = 0;
    try
    con = DriverManager.getConnection("url","root","root");
    ps = con.createStatement();
    rs = ps.executeQuery("select * from user");
    while(rs.next()){
    System.out.println(rs.getString(1));
    perInfoAll.add(i,new perInfo(rs.getString(1),rs.getString(2),rs.getString(3)));
    i++;
    catch (Exception e)
    System.out.println("Error Data : " + e.getMessage());
    return perInfoAll;
    public class perInfo {
    String uname;
    String firstName;
    String lastName;
    public perInfo(String firstName,String lastName,String uname) {
    this.uname = uname;
    this.firstName = firstName;
    this.lastName = lastName;
    public String getUname() {
    return uname;
    public String getFirstName() {
    return firstName;
    public String getLastName() {
    return lastName;
    ADF table code:
    <af:table value="#{tableBean.perInfoAll}" var="row"
    binding="#{backing_Display.table1}" id="table1">
    <af:column sortable="false" headerText=""
    align="start">
    <af:outputText value="#{row.firstName"/>//---> Jdeveloper 11g doesn't allow me to use this.. it says firstName is an unknown property..
    </af:column>
    </af:table>
    Please tell me is this the way to do it.. or is it a must to use the DataCollection from the data controls panel...
    Thanks...

  • Show results from the database to html tables?

    Hi,
    I am a PHP programmer and did a successful CMS program for a company. Now I have another project which is a web based system.
    I basically know how to do it and finish it in PHP.. but I am trying to do it using J2EE.. I am trying to learn J2EE now since I have been programming
    on J2SE for quite sometime..
    I am trying to show the results from a MySQL database on a table on J2EE but I am having hard time doing that. I am trying to research online and reading books but with no luck I can't find any resources on how to do that..If you guys can lead me into a resource where I can read how to do it? or just give any ideas on how to do it correctly I'll try to read and learn I will very much appreciate it.. here's my coding please look at it. Thank you very much
    I want to make it like this in a html table:
    userid username activated task
    1 alvin y delete(this will be a link to delete the user)
    Right now this is what I was able to do so far:
    Userid username activated task
    1
    alvin
    y
    Here are my codes... I am not even sure if I am doing it in the correct way...
    User.java
    mport java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    public class Users {
    public List getUsers(){
    List names = new ArrayList();
    try{
    Connection con = DBConnect.getConnection();
    Statement stmt = con.createStatement();
    String sql = "select * from users";
    ResultSet rs = stmt.executeQuery(sql);
    while(rs.next())
    String userid = rs.getString("user_id");
    String usernames = rs.getString("user_name");
    String password= rs.getString("password");
    String activated= rs.getString("activated");
    names.add(userid);
    names.add(usernames);
    names.add(password);
    names.add(activated);
    catch(SQLException e)
    System.out.print(e);
    catch(Exception e)
    System.out.print(e);
    return names;
    UserServlet.java
    import java.io.IOException;
    import java.util.List;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class UsersServ extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Users be =new Users();
    List result = be.getUsers();
    request.setAttribute("user_results", result);
    RequestDispatcher view = request.getRequestDispatcher("manage_users1.jsp");
    view.forward(request, response);
    manage_users1.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@page import = "java.util.*" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    List results = (List)request.getAttribute("user_results");
    Iterator it = results.iterator();
    out.print("<table border = 1>");
    out.print("<th>");
    out.print("userid");
    out.print("</th>");
    out.print("<th>");
    out.print("username");;
    out.print("</th>");
    while(it.hasNext()){
    out.print("<tr><td> " + it.next()+"</td></tr>");
    out.print("</table>");
    %>
    </body>
    </html>

    I suggest:
    1: you use this:
    e.printStackTrace()
    instead of this:
    System.out.print(e);
    so it will tell you what line it crashed on.
    2: In the code below,here is how you mix coding html tags and java scriptlets
    (you should never have to use out.print()):. In a later project, you can learn how to use JSTL
    instead of java scriplets (I suggest using java scriptlets for now until you have more JSP experience).
    FROM:
    <html>
    <%
    //some java code goes here
    out.print("<th>");
    //some more java code goes here
    out.print("<tr>");
    %>
    TO:
    <html>
    <% //some java code goes here%>
    <th>
    <%//some more java code goes here%>
    <tr>
    3: Put a lot of System.println() statements in your *.java classes to verify what its doing (you can learn how to use a debugger later).
    4: I highly recommend reading a book on JSP/servlets cover to cover.
    Here's a simple MVC design approach I previously posted:
    http://forums.sun.com/thread.jspa?messageID=10786901

  • Display BLOB from remote database

    Context: We are offloading documents (pdf) from our OLTP database to a dedicated 'output database.' These documents must be displayed from the application on our OLTP database using a database link. Various posts show that querying a BLOB from a remote database can best be implemented using a query on the remote table and an insert on a local (temporary) table. So far, so good. The idea is to display this BLOB using wpg_docload.download_file.
    BUT:
    When trying to display the pdf from this global temporary table an error occurs:
    ORA-14453: attempt to use a LOB of a temporary table, whose data has already been purged
    When trying to display from a normal table and issuing a rollback after wpg_docload.download_file results in another error:
    ORA-22922: nonexistent LOB value
    When trying to display from a normal table and not removing the record in any way, its works fine. Only I now have a garbage collection issue, because the remote date remain in my local (preferably temporary) table.
    It seems to me that mod_plsql needs an active session to display my pdf.
    Does anyone have an explanation for this behaviour and maybe a solution for my problem?
    Environment:
    local: 10.2.0.4.0
    remote: 11.1.0.7.0
    pdf size: ca. 150kB
    code used:
    PROCEDURE show_doc (p_nta_id IN NUMBER
    ,p_sessie IN NUMBER
    IS
    t_lob BLOB;
    t_lob2 BLOB := empty_blob();
    t_mime VARCHAR2(100);
    BEGIN
    -- copy BLOB into local global temp table
    INSERT INTO mvs_tmp_notaprint_bestanden
    npv_nta_id
    , npv_npe_sessie
    , mime_type
    , bestand
    ) -- from remote table
    SELECT npd.npv_nta_id
    ,npd.npv_npe_sessie
    ,npd.mime_type
    ,npd.bestand
    FROM mvs_notaprint_bestanden@marc npd
    WHERE npd.npv_nta_id ; = p_nta_id
    AND npd.npv_npe_sessie = p_sessie
    -- show BLOB from local global temp table
    SELECT t.bestand
    , t.mime_type
    INTO t_lob
    , t_mime
    FROM mvs_tmp_notaprint_bestanden t
    WHERE t.npv_nta_id ; = p_nta_id
    AND t.npv_npe_sessie ; = p_sessie
    t_lob2 := t_lob; -- buffer BLOB
    owa_util.mime_header(t_mime , FALSE );
    owa_util.http_header_close;
    wpg_docload.download_file(t_lob2);
    END show_doc;

    Andrew,
    thank you, the 'preserve rows' did the trick.
    Every query from a browser (even in the same browser session) is a new Oracle session, so the copied records in the global temporary table are gone after the page is displayed.
    Am I correct in assuming that each call from the browser results in a new Oracle session? I did a few tests and found for each call a different sessionid.
    Sincerly,
    Arne Suverein
    Edited by: Arne Suverein on Aug 18, 2009 3:35 PM

  • Display Image from the database but prevent it from refreshing on every pages

    Hi there,
    I can see there are many discussions around this but my query is slightly different. I'm writing this on behalf of one of my developers. (sorry for my ignorance on techie stuff.. :-))
    A logo is being displayed on a few pages, which is called from the database. However, the problem is that  - this logo refreshes every time when you traverse to each page causing a performance issue or sometimes slow loading of the image.
    My question is - how do we stop it from loading on each page from the database?.  I would rather load once when the main page loads initially and then maintain this on other pages too.
    We can keep this logo on a file system (FS)  and display it via CSS/HTML/frame but since we want to keep it flexible/dynamic where a user can upload a new one whenever it changes and hence DB seems to be the suitable option (in my opinion).
    Can someone please help?
    If you need any further info around the coding how it is being done at present, pls let me know.
    Thank you

    read this http://docs.oracle.com/cd/B28359_01/appdev.111/b28393/adlob_tables.htm#g1017777
    you can cache lobs in the database too
    you can also upload the pic in your file system using utl_file package and then put the image in the working directory mentioned in i.war
    you can then reference the image and it will not be stored in the database and will be cached
    Regards,
    Vishal
    Oracle APEX 4.2 Reporting | Packt Publishing
    Vishal's blog

  • VM04: data transfering from specification database to table MGEF

    Hello everyone,
    I've customised for running VM04 in IMG.
    I've assigned the Hazardous Material number 11 to the Material 1666.
    I've assigned the Material 1666 to the Agent P182.
    But after running VM04, the data of Hazardous Material 11 which is in table MGEF (T-code: VM03) is still not covered by the data of P182 from specification database.
    Could anybody look for the reason for me, please?
    Thanks!

    Hello
    The MGEF approach as a very old one. Form legla perspective it is not useful any more.
    Documentation can be found here (e.g)
    http://help.sap.com/saphelp_45b/helpdata/en/35/71880186c2223ae10000009b38f984/content.htm
    I assume you have performed all necessary customizing activities? Do you receive error messages ??
    Furthermore may be take a look here:
    Need Warehouse Management Tables in SAP
    http://help.sap.com/printdocu/core/print46c/en/data/pdf/LEWM/MMWM.pdf
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0e8c107-0435-2e10-a5bc-e295ed04049b?quicklink=index&overridelayout=true
    It is recommended from legal perspective to use eWM and not WM any more or at least the new WM approach as described in
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0e8c107-0435-2e10-a5bc-e295ed04049b?quicklink=index&overridelayout=true
    With best regards
    C.B.
    Edited by: Christoph Bergemann on May 7, 2011 1:42 PM

  • Display results from dynamic query created and executed inside procedure

    Hi;
    I have created this code:
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, VAR3 IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    end RunDynamicQuery;
    How can I run this procedure and see the result on the dymanic query generated inside it?
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Expected Output for this given example:
    20-05-2009 11:04:44 ( the result of the dymanic query inside the procedure variable MainQuery :='select sysdate from dual';)
    I tested with 'execute immediate':
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, filter IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    execute immediate (MainQuery );
    end RunDynamicQuery;
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Output:"Statement processed'' (no sysdate displayed ! )
    Please consider that the collums in the query are always dynamic... PIPELINE Table would not work because I would need to define a container, example:
    CREATE OR REPLACE TYPE emp_tabtype AS TABLE OF emp_type;
    FUNCTION RunDynamicQuery (p_cursor IN sys_refcursor)
    RETURN emp_tabtype PIPELINED
    IS
    emp_in emp%ROWTYPE;
    BEGIN
    LOOP
    FETCH p_cursor
    INTO emp_in;
    EXIT WHEN p_cursor%NOTFOUND;
    PIPE ROW (...)

    That would be a nice solution, thanks :)
    ''For now'' I implemented like this:
    My dynamic query now returns a single string ( select col1 || col2 || col3 from bla)
    This way I don't have dynamic collumns issue, and from business side, this ''string'' format works for them.
    This way I can use the pipelines to get the result out...
    OPEN myCursor FOR MainQuery;
    FETCH myCursor
    INTO myRow;
    WHILE (NOT myCursor%notFound) LOOP
    PIPE ROW(myRow);
    FETCH myCursor
    INTO myRow;
    END LOOP;
    CLOSE myCursor;

  • How to display data from a database to a  JComboBox  JTextField

    Hello
    I was wondering I have a database called "PAYTYPE" and have a colums called
    EMPLOYEETYPE     PAYBASIC     PAYSUNDAY     PAYHOLIDAY     PAYPERIOD
    What i want to do is display the list of EMPLOYEETYPE in a combo box(Which i got this part working),
         try{
              ResultSet rs = db.getResult("Select * FROM PAYTYPE");
              while(rs.next())
                   payTypeField.addItem(rs.getString(2));
              }catch(SQLException e)
              }When an item is selected from the combo box then the information thats in PAYBASIC,PAYSUNDAY,PAYHOLIDAY, PAYPERIOD will be displayed in textfields
    this is the problem im trying to solve
    Any Ideas ??????

    What im trying to do is the following
    on my Gui i have 1 JComboBox and 3 JtextFields
    The Jcombo box is populated by the data base
    try{     
              ResultSet rs = db.getResult("Select * FROM EMPLOYEEPAYTYPE");
              while(rs.next())
                   payTypeField.addItem(rs.getString(2));
              }catch(SQLException e)
              }Now that i have the JComboBox filled I want the other 3 JTextField to be populated with the information that been selected by the JComboBox
    I under stand there needs to be a .addActionListener(this) to the JComboBox
                    payTypeField = new JComboBox();
                payTypeField.setBounds(130, 10,100,20);
                payTypeField.addActionListener(this);
                payTypeField.addItemListener(this);
                 c.add(payTypeField);I would just like the steps that i need to take in order to fill the JTextBoxes in pudoscode
    The information that i need will need to be pulled from the database - EMPLOYEEPAYTYPE
    Thanks
    Jon

  • Dificulty in displaying results from 2 tables

    Hi Experts,
    I have created a form that needs to display 2 different tables in the form. However, the second table only shows the results after all the records from the first are listed. I need to show both the tables in page 1 and continue to show the records in the succeeding pages. I have put the tables each in their different subforms and enclosed them in another subform but the entries from table 2 still does not show. Could you tell me what am I missing?
    Thanks and more power.
    Regards,
    Rare

    Hi,
    What is the cardinality of the nodes that these tables are mapped to?
    Is it 1..n or 0..n?
    If it is 0..n then this is where the problem may be..
    Try setting the minimum count of the second table to 1 in the binding tab in the livecycle designer..
    Also, make sure the paginatinof the two sub forms is set to Flowed..
    Hope this helps.
    Rgds, Amith

  • Problem with displaying records from the database in a table ui element

    Hi,
    Iam creating an application which retrieves data from an oracle database. Iam able to connect to the database and retrieve the data in a result set. Then I try to set these values in a context node as follows,
    while (resultSet.next()) {
    String name = result.getString(1);
    String EmpId = result.getString(2);
    IEmpNode node = wdContext.nodeEmp();
    IEmpElement el = node.createEmpElement();
    el.setName(name);
    el.setEmpId(EmpId);
    node.addElement(el);
    where the context structure is emp(node)
                                   ---name(attribute)
                                   ---empId(attribute)
    Then I have bound the node emp to a table ui element.If I try to deploy this it comes up with Internal Server error.
    But if try this way, without creating a node, only with attributes name and empId,
    wdContext.currentContextElement.setName(name);
    wdContext.currentContextElement.setEmpId(EmpId);
    and binding the attributes to inputfields in the view, Iam able to see the last record in the database table.
    So where am I going wrong while using the table ui element?
    Regards,
    Rachel

    Hi
    Try this
    //Create the node in outer of while loop and bind to Table UIElement
    IEmpNode node = wdContext.nodeEmp();
    while (resultSet.next()) {
    String name = result.getString(1);
    String EmpId = result.getString(2);
    IEmpElement el = wdContext.createEmpElement();
    el.setName(name);
    el.setEmpId(EmpId);
    node.addElement(el);
    Kind Regards
    Mukesh

  • Problem displaying results from a SQL database

    Hey everyone,
    So I am basically fairly new to coding, i am doing a tutorial i found on the web and trying to implement into my own. I have gotten so far in it and now have struck a problem, when i search for a item in a database it wont find it and a previous problem i had was that it was displayin all the records instead of the searched records. Anyway here is my code and i would greatly appreciate any help as i am stuck on it for weeks now trying to change is around and its really disheartening. P.S. The link to the tutorial if its any help is:http://www.sebastiansulinski.co.uk/web_design_tutorials/tutorial/9/link_exchange_system_wi th_dreamweaver_cs3
    Thanks
    Frank
    <?php require_once('../Connections/cbdb.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $maxRows_rsStock = 20;
    $pageNum_rsStock = 0;
    if (isset($_GET['pageNum_rsStock'])) {
      $pageNum_rsStock = $_GET['pageNum_rsStock'];
    $startRow_rsStock = $pageNum_rsStock * $maxRows_rsStock;
    mysql_select_db($database_cbdb, $cbdb);
    // Search engine functionality
    if ($_GET['make'] || $_GET['model']) {
    $key = $_GET['make'];
    $categ = $_GET['model'];
    $query_rsStock = "SELECT * FROM stock WHERE stock.model LIKE '%$make%' AND stock.model LIKE '%$model%' ORDER BY stock.date DESC";
    } else {
    $query_rsStock = "SELECT * FROM stock ORDER BY date DESC";
    $query_limit_rsStock = sprintf("%s LIMIT %d, %d", $query_rsStock, $startRow_rsStock, $maxRows_rsStock);
    $rsStock = mysql_query($query_limit_rsStock, $cbdb) or die(mysql_error());
    $row_rsStock = mysql_fetch_assoc($rsStock);
    if (isset($_GET['totalRows_rsStock'])) {
      $totalRows_rsStock = $_GET['totalRows_rsStock'];
    } else {
      $all_rsStock = mysql_query($query_rsStock);
      $totalRows_rsStock = mysql_num_rows($all_rsStock);
    $totalPages_rsStock = ceil($totalRows_rsStock/$maxRows_rsStock)-1;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <!-- InstanceEndEditable -->
    <link href="../style/admin_style.css" rel="stylesheet" type="text/css" media="screen" />
    <!-- InstanceBeginEditable name="head" --><title>Stock List</title>
    <script type="text/javascript">
    function tmt_confirm(msg){
    document.MM_returnValue=(confirm(unescape(msg)));
    </script>
    <!-- InstanceEndEditable -->
    </head>
    <body>
    <div id="wrapper">
    <div id="header"><p>Admin</p></div>
    <div id="navigation">
    <ul id="mainav">
    <li><a href="stock_list.php">List of stock</a></li>
    <li><a href="stock_add.php">Add new stock</a></li>
    <li><a href="make_add.php">Makes</a></li>
    <li><a href="logout.php">Logout</a></li>
    <li id="front"><a href="C:\xampp\htdocs\CarBreakers" target="_blank">front</a></li>
    </ul>
    </div>
    <div id="container"><!-- InstanceBeginEditable name="Content" -->
      <p id="ptitle">Stock</p>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" id="forminsert">
      <table border="0" cellspacing="0" cellpadding="0" id="tblinsert">
      <caption>
        Search for Stock
      </caption>
      <tr>
        <th><label for="keyword">Make:</label></th>
        <td><input type="text" name="make" id="make" /></td>
        <th><label for="model">Model:</label></th>
        <td><input type="text" name="model" id="model" /></td>
        <td><input type="submit" id="button" value="Submit" /></td>
      </tr>
    </table>
      </form>
      <?php if ($totalRows_rsStock > 0) { // Show if recordset not empty ?>
          <?php if ($totalRows_rsStock == 0) { // Show if recordset empty ?>
      <p>Sorry, there are no records matching your searching criteria.</p>
      <?php } // Show if recordset empty ?>
    <table border="0" cellpadding="0" cellspacing="0" id="tblrepeat">
        <tr>
          <th width="63" scope="col">Make</th>
          <th width="67" scope="col">Model</th>
          <th width="59" scope="col">Year</th>
          <th width="79" scope="col">Engine cc</th>
          <th width="56" scope="col">Fuel</th>
          <th width="59" scope="col">Doors</th>
          <th width="56" scope="col">Body</th>
          <th width="104" scope="col">Arrival Date</th>
          <th width="51" scope="col">Edit</th>
          <th width="83" scope="col">Remove</th>
        </tr>
        <?php do { ?>
          <tr>
            <td><?php echo $row_rsStock['make']; ?></td>
            <td><?php echo $row_rsStock['model']; ?></td>
            <td><?php echo $row_rsStock['year']; ?></td>
            <td><?php echo $row_rsStock['cc']; ?></td>
            <td><?php echo $row_rsStock['fuel']; ?></td>
            <td><?php echo $row_rsStock['doors']; ?></td>
            <td><?php echo $row_rsStock['body']; ?></td>
            <td><?php echo $row_rsStock['date']; ?></td>
            <td><a href="stock_edit.php?id=<?php echo $row_rsStock['stockId']; ?>">Edit</a></td>
            <td><a href="stock_remove.php?id=<?php echo $row_rsStock['stockId']; ?>" onclick="tmt_confirm('Are%20you%20sure%20you%20want%20to%20perform%20this%20action?');ret urn document.MM_returnValue">Remove</a></td>
          </tr>
          <?php } while ($row_rsStock = mysql_fetch_assoc($rsStock)); ?>
    </table>
      <?php } // Show if recordset not empty ?>
    <!-- InstanceEndEditable --></div>
    <div id="footer"><p>© <a href="http://www.blablabla.com/" title="Web Designer" target="_blank">Web Design</a></p></div>
    </div>
    </body>
    <!-- InstanceEnd --></html>
    <?php
    mysql_free_result($rsStock);
    ?>

    In your code, you have this -
    // Search engine functionality
    if ($_GET['make'] || $_GET['model']) {
    $key = $_GET['make'];
    $categ = $_GET['model'];
    $query_rsStock = "SELECT * FROM stock WHERE stock.model LIKE '%$make%' AND stock.model LIKE '%$model%' ORDER BY stock.date DESC";
    } else {
    $query_rsStock = "SELECT * FROM stock ORDER BY date DESC";
    The "else" part of the "if" block is what is selecting ALL the records -
    $query_rsStock = "SELECT * FROM stock ORDER BY date DESC";
    This means that the "if" part of the "if" block is always failing.  When does it fail?  Whenever you have not passed a URL variable for either "make" or "model".  Are you sure you are correctly passing that variable?

  • Want to display results from database pagewise ?

    I have 500 records in the sql server 2000 then i query and retrieve them in a resultsets. and then i want to display 10 records per page having the facility to navigate to the Previous and Next Record also going to first and the last record.
    like we are using when we navigate from this forum
    FIRST PREVIOUS 1 2 3 4 5 6 7 8 9 10 NEXT LAST
    secondly if their is a possiblity their should be a search page to to specific page like this
    Go To this Page (Textfield)
    third thing when i am on first record the it shouldnt show PREVIOUS button and when it is in the last it should not show NEXT.
    this thing should be done by Using JSP , Servelets and Beans...
    and PLEASE DONT SAY THAT IT HAS ALREADY BEEN ASK IF SO TELL ME THE LINK BECAUSE I CANT FIND ANYWHERE IN THE FORUM SO PLEASE TRY TO PROVIDE THE SOURCODE OR ATLEAST A REFERENCE FOR IT.

    for your task there is nice keyword in MySQL:
    LIMIT [offset,] rows
    maybe MSSQL has something similar...
    though i haven't seen such a keyword in oracle nor postgre... nor mssql (but i haven't looked for it from there...)
    one way would be to skip first X results in resultset... in PyML i have used method .skip(count) for skiping count rows, but i'm not sure that in java there is equivalent for that, so you might have to just call ResultSet.next() for count times, and then ten more times to get desired data for your page.

Maybe you are looking for

  • Windows 8.1 Fails to Boot Error 0xc000000f

    My friend's notebook developed an error message on booting after less than a week's usage. The error reads: Windows failed to start. A recent hardware or software change might be the cause. Ti fix the problem: 1. Insert Windows installation disk and

  • SRM-MDM Catalog - issue in the Portal (Employee Self-Services - Shopping C)

    Dear SAP, When we quit a web page in SRM-JAVA system, we get this issue in our production system. We do not have this issue to our DEV and QAS system : ============================================================ Exception occured during processing o

  • Usage of RSUPGRCHECK report in BW7 environment

    Hello folks, have you some experience with usage of RSUPGRCHECK report in BW7 environment? I'm trying to find some tool in BW to explore what objects went inactive after import of high volume of transport request. We are planning to go live recently

  • My music quality drops half way through - wave file, is there a way to make an improvement

    My music sound quality drops half way through - its a wave file, is there a way to make a the other half as good as the first half?

  • Prinitng Wirelessly

    I have the airport extreme connected to a windows machine desktop. no issues at all. my macbook pro connects perfectly. the macbook pro accesses the usb harddrive without any problems. when i try to print from the macbook pro, the system reads the pr