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.

Similar Messages

  • 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

  • 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.

  • Display Autonumber from Access Database when click insert button

    I have an application that displays all the customers in my Access database. The primary key is an Autonumber that Access generates.
    How can I display the autonumber that Access generates when I click my insert new record button?

    The generated autonumber can be retrieved with a SELECT @@IDENTITY which is the same syntax as in SQLServer. When this statement is executed it is effectively asking for the last 'identity' value seen on the current connection which will be the ID of the row you just created with your INSERT statement.

  • 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.

  • Error while trying to retrieve data from BW BEx query

    The following error is coming while trying to retrieve data from BW BEx query (on ODS) when the Characters are more than 50.
    In BEx report there is a limitation but is it also a limitation in Webi report.
    Is there any other solution for this scenario where it is possible to retrieve more than 50 Characters?
    A database error occured. The database error text is: The MDX query SELECT  { [Measures].[3OD1RJNV2ZXI7XOC4CY9VXLZI], [Measures].[3P71KBWTVNGY9JTZP9FTP6RZ4], [Measures].[3OEAEUW2WTYJRE2TOD6IOFJF4] }  ON COLUMNS , NON EMPTY CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( [ZHOST_ID2].[LEVEL01].MEMBERS, [ZHOST_ID3].[LEVEL01].MEMBERS ), [ZHOST_ID1].[LEVEL01].MEMBERS ), [ZREVENDDT__0CALDAY].[LEVEL01].MEMBERS ) ........................................................ failed to execute with the error Invalid MDX command with UNSUPPORTED: > 50 CHARACT.. (WIS 10901)

    Hi,
    That warning / error message will be coming from the MDX interface on the BW server.  It does not originate from BOBJ.
    This question would be better asked to support component BW-BEX-OT-MDX
    Similar discussion can be found using search: Limitation of Number of Objects used in Webi with SAP BW Universe as Source
    Regards,
    Henry

  • How to present results from a sql-query in java

    Hi - I'm having problems finding out how to present data from a database-query in a nice looking way in a JFrame. Want to present them similar to the way they are presented in the database. Is there an easy way doing this?

    Tried to use a JTable, but it's difficult when data in the table should be able to change all the time, i.e the number of rows. What is a Html-table? Can i use it in an application?

  • Upload data from Access Database to Oracle Database In oracle 8i

    hi everybody
    i am trying upload data from Access database to Oracle Database
    i have TT(F1,F2,F3) table in Access Databsse
    and emp(ename,ecode,sal) in oracle Database
    db_ac is my datasource name
    when i connect to Access Database thru this command this show following error
    SQL> connect a/a@odbc:db_ac;
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    Error accessing PRODUCT_USER_PROFILE
    Warning: Product user profile information not loaded!
    You may need to run PUPBLD.SQL as SYSTEM
    Server not available or version too low for this feature
    ORA-00022: invalid session id; access denied
    Connected.
    when i am trying copy data as this command it show error and data not copied.
    SQL> COPY FROM A/A@ODBC:DB_AC TO test/test@ora INSERT EMP USING SELECT F1,F2,F3 FROM TT;
    Array fetch/bind size is 15. (arraysize is 15)
    Will commit when done. (copycommit is 0)
    Maximum long size is 80. (long is 80)
    ORA-00022: invalid session id; access denied
    ERROR:
    OCA-00022: general OCA error
    can help me .
    with thanx

    Hi there,<br>
    <br>
    Please kindly use instead the Database Forum at:-<br>
    General Database Discussions<br>
    <br>
    ... to place your question as this is for the Oracle Portal product Export / Import functionality.<br>
    <br>
    <br>
    Kind regards,<br>
    Pedro.

  • 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...

  • Data access from Access Database

    I want collect some data from access, I have created a frame with swing componet, now when I am searching data with some variable from Access database , it is not comming, but in simple case all data are comming in differnt places in my frame.
    The string which I used is
    st.executeQuery("Select * from student where cid = '+st1+'"
    where st1 is avariable collected some data from the frame, it is tested ok.
    now i never did practice with access, please if there is any wrong .

    Could you include more code please? The single statement you have provided seems fine, but we're not psychic.

  • How to configure search results web part to display results only after a query is generated from user?

    Hi All,
    I am crawling documents from a file server. I created a new content source and crawled the documents. All documents are crawled successfully.
    Then I went to my enterprise search center site collection and created a new result source. I have added the query to use above content source.
    After that, on a page I am trying to configure the search results web part to display documents using this result source. Now the problem is:
    It displays all the documents that are crawled without searching for anything. I mean first it should not display any results. If a user searches for something , then according to that search it should display results.
    Any idea how to do this in the web part? I am using SharePoint 2013 on premise enterprise edition. No code. Totally OOTB.

    Hi Mohan,
    What did you use for the Query text in the result source?
    I could reproduce this issue when I used Query text like: {searchTerms} Path:”http://sps2k13sp/sites/First/Shared%20Documents”
    Then I changed the Query to
    {?{searchTerms}
    Path:"http://sps2k13sp/sites/First/Shared%20Documents"}
    , then Search result web part didn’t return results without searching.
    So , check your result source, and use the Query like the above(adding "{?...}").
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • How to generate XML file from oracle database query result

    Hi dudes,
    as stated on the subject, can anyone suggests me how can i achieve the task stated above??
    Here is a brief description of my problem:
    I need to create a XML file once i query from the oracle database, and the query result returned from the database will be stored in XML file.
    I'd searched around the JAXB, DOM, SAXP and the like basic concepts, but i still don't know how to start??
    Any suggestions ???

    Read this:
    http://www.cafeconleche.org/books/xmljava/chapters/ch08s05.html
    You might have to read more of the book to understand that chapter.

  • 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;

  • Access database query resultset in java scriptlet

    Question:
    1) I am Creating a web page and plotting points on the page:
    2) Database query results in decimal values dec_latitude and dec_longiitude.
    3) Perform calculations on lati. & long. in a java scriptlet to create a plot position (xpos, ypos).
    4) Send the xpos and ypos back to the java server page
    5) Use <IMG and absolute positioning to plot the point at position xpos, and ypos.
    6) Repeat until all rows in the query result set have been plotted.
    I don't know how to pass the dec_latitude and dec_longitude to the java scriptlet.
    After the java scriptlet calculation translates the latitude and longitude
    into xpos and ypos, I need to pass the xpos and ypos back to the java server page so that a data point is plotted on a map at position xpos, ypos.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    The code below results in a runtime error.
    Am I supposed to create a java object and access that in the java scriptlet? Can the java scriptlet access the latvar and longvar created during the "<c:set var="latvar"... ?
    If not, what mechanisum do I use to access the resulting colums: dec_latitude and dec_longitude? I need the java scriptlet to convert the
    dec_latitude and dec_longitude into a display position based on the number of pixels from the TOP and LEFT (xpos, ypos). Then plot of the data point using the IMG and (xpos, ypos). This will overlay a map whose z-index is lower than the plotted data point.
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar"); <--- runtime error !!!!
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    </c:forEach>

    Thanks
    I still get a runtime error: I translated the code you gave to code below .... which I think is equivalent. See Below: I'm still learning about this stuff so I may not have not translated this properly. Do
    you see what I am doing wrong?
    Best Regards,
    - John
    %@ page language="java" contentType="text/html;
    charset=ISO-8859-1"%>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ page import="java.lang.Math"%>
    <sql:setDataSource dataSource="jdbc/SampleDB" />
    <c:set var="genus_name" value="${param.genus_name}" />
    <c:set var="species_name" value="${param.species_name}" />
    <c:set var="species_common_name" value="${param.species_common_name}" />
    <c:set var="dd_sighted" value="${param.dd_sighted}" />
    <c:set var="mm_sighted" value="${param.mm_sighted}" />
    <c:set var="yyyy_sighted" value="${param.yyyy_sighted}" />
    <c:set var="species_state" value="${param.species_state}" />
    <c:set var="species_county" value="${param.species_county}" />
    <c:set var="species_country" value="${param.species_country}" />
    <c:set var="dec_latitude" value="${param.dec_latitude}" />
    <c:set var="dec_longitude" value="${param.dec_longitude}" />
    <c:set var="notes" value="${param.notes}" />
    <c:set var="person_first_name" value="${param.person_first_name}" />
    <c:set var="person_last_name" value="${param.person_last_name}" />
    <c:set var="person_street" value="${param.person_street}" />
    <c:set var="person_city" value="${param.person_city}" />
    <c:set var="person_state" value="${param.person_state}" />
    <c:set var="person_zip" value="${param.person_zip}" />
    <c:set var="person_country" value="${param.person_country}" />
    <c:set var="person_email" value="${param.person_email}" />
    <h2>Species Sightings:</h2>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Breckenridge Citizen Bio-Survey Selective Output Page</title>
    </head>
    <body>
    Izaak Walton League of America
    <h1>Breckenridge Citizen Bio-Survey Selective Output</h1>
    <HR>
    <c:if test="${param.action == 'Submit'}">
    <%int xpos = 0;
         int ypos = 0;
         float latitude = 0.0F;
         float longitude = 0.0F;
         float latitudeMpls = 45.06F;
         float longitudeMpls = -93.14F;                    int xposMpls = 1205 - (int) Math.round(latitudeMpls);
         int yposMpls = 735 + (int) Math.round(longitudeMpls);
    %>
    <IMG SRC="minnesota_1990.jpg" ALT="minesota map" style="z-index:1;"> <----- THIS WORKS FINE
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2"> <----- THIS WORKS FINE FOR HARDCODED MPLS XPOS AND YPOS
    <sql:query var="qryBio">
    SELECT
    PERSON_FIRST_NAME,
    PERSON_LAST_NAME,
    GENUS_NAME,
    SPECIES_NAME,
    SPECIES_COMMON_NAME,
    SPECIES_COUNTY,
    SPECIES_STATE,
    SPECIES_COUNTRY,
    DD_SIGHTED,
    MM_SIGHTED,
    YYYY_SIGHTED,
    DEC_LATITUDE,
    DEC_LONGITUDE,
    NOTES,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    genus_name like rtrim(upper('${genus_name}')) AND
    species_name like rtrim(upper('${species_name}')) AND
    species_common_name like rtrim(upper
    ('${species_common_name}')) AND
    species_state like rtrim(upper('${species_state}')) AND
    species_county like rtrim(upper('${species_county}')) AND
    species_country like rtrim(upper('${species_country}')) AND
    person_first_name like rtrim(upper('${person_first_name}')) AND
    person_last_name like rtrim(upper('${person_last_name}')) AND
    person_email like rtrim(upper('${person_email}'))
    </sql:query>
    <c:forEach var="row" items="${qryBio.rows}">
    <--- THE LINE ABOVE WORKS FINE --->
    <c:set var="latvar" value="${row.dec_latitude}" scope="page" />
    <c:set var="longvar" value="${row.dec_longitude} " scope="page" />
    <%
    latitude =
    Float.parseFloat((String)pageContext.getAttribute("latvar"));
    <--- RUNTIME ERROR OCCURS HERE --- SEE LINE ABOVE --->
    longitude =
    Float.parseFloat((String)pageContext.getAttribute("longvar"));
    xpos = (int) Math.round(latitude);
    ypos = (int) Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    request.setAttribute("xpos",new Integer(xpos));
    request.setAttribute("ypos",new Integer(ypos));
    %>
    IIMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    <--- THIS (ABOVE) WORKS FINE WITH CORRECT VALUES FOR XPOS AND YPOS WHEN RUNTIME ERROR DOES NOT OCCUR --->
    </c:forEach>
    </c:if>

  • Trying to connect GUI to access database

    i need alittle help i have this GUI that i created and i am trying to hook it up to a database in MS ACCESS and i am have so many problems trying to get my second table called billings to pull and show up in my GUI please take a look at my code and tell me what is wrong with it.
    now on my GUI its supposed to allow you to choose a company in the list box and after choosing a company, this allows you to get all the company's information like address and state and zip code and another list box is populated called consultants and you can choose a consultant and gethis or her billing information , like their hours billed from that company and their total hours billed
    please look at my code and tell me what is wrong, especially with the part about pulling information from the database.
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Project extends Frame implements ItemListener, ActionListener
    //Declare database variables
    Connection conconsultants;
    Statement cmdconsultants;
    ResultSet rsconsultants;
    boolean blnSuccessfulOpen = false;
    //Declare components
    Choice lstNames = new Choice();
    TextField txtConsultant_Lname = new TextField(10);
    TextField txtConsultant_Fname = new TextField(10);
    TextField txtTitle = new TextField(9);
    TextField txtHours_Billed = new TextField(14);
    Button btnAdd = new Button("Add");
    Button btnEdit = new Button("Save");
    Button btnCancel = new Button("Cancel");
    Button btnDelete = new Button("Delete");
    Label lblMessage = new Label(" ");
    public static void main(String args[])
    //Declare an instance of this application
    Project thisApp = new Project();
    thisApp.createInterface();
    public void createInterface()
    //Load the database and set up the frame
    loadDatabase();
    if (blnSuccessfulOpen)
    //Set up frame
    setTitle("Update Test Database");
    addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent event)
    stop();
    System.exit(0);
    setLayout(new BorderLayout());
    //Set up top panel
    Panel pnlTop = new Panel(new GridLayout(2, 2, 10, 10));
    pnlTop.add(new Label("Last Name"));
    lstNames.insert("Select a Name to Display", 0);
    lstNames.addItemListener(this);
    pnlTop.add(lstNames);
    pnlTop.add(new Label(" "));
    add(pnlTop, "North");
    //Set up center panel
    Panel pnlMiddle = new Panel(new GridLayout(5, 2, 10, 10));
    pnlMiddle.getInsets();
    pnlMiddle.add(new Label("Consultant_Lname"));
    pnlMiddle.add(txtConsultant_Lname);
    pnlMiddle.add(new Label("Consultant_Fname"));
    pnlMiddle.add(txtConsultant_Fname);
    pnlMiddle.add(new Label("Title"));
    pnlMiddle.add(txtTitle);
    pnlMiddle.add(new Label("Hours_Billed"));
    pnlMiddle.add(txtHours_Billed);
    setTextToNotEditable();
    Panel pnlLeftButtons = new Panel(new GridLayout(0, 2, 10, 10));
    Panel pnlRightButtons = new Panel(new GridLayout(0, 2, 10, 10));
    pnlLeftButtons.add(btnAdd);
    btnAdd.addActionListener(this);
    pnlLeftButtons.add(btnEdit);
    btnEdit.addActionListener(this);
    pnlRightButtons.add(btnDelete);
    btnDelete.addActionListener(this);
    pnlRightButtons.add(btnCancel);
    btnCancel.addActionListener(this);
    btnCancel.setEnabled(false);
    pnlMiddle.add(pnlLeftButtons);
    pnlMiddle.add(pnlRightButtons);
    add(pnlMiddle, "Center");
    //Set up bottom panel
    add(lblMessage, "South");
    lblMessage.setForeground(Color.red);
    //Display the frame
    setSize(400, 300);
    setVisible(true);
    else
    stop(); //Close any open connection
    System.exit(-1); //Exit with error status
    public Insets insets()
    //Set frame insets
    return new Insets(40, 15, 15, 15);
    public void loadDatabase()
    try
    //Load the Sun drivers
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch (ClassNotFoundException err)
    try
    //Load the Microsoft drivers
    Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver");
    catch (ClassNotFoundException error)
    System.err.println("Drivers did not load properly");
    try
    //Connect to the database
    conconsultants = DriverManager.getConnection("jdbc:odbc:Test");
    //Create a ResultSet
    cmdconsultants = conconsultants.createStatement();
    rsconsultants = cmdconsultants.executeQuery(
    "Select * from consultants; ");
    loadNames(rsconsultants);
    blnSuccessfulOpen = true;
    catch(SQLException error)
    System.err.println("Error: " + error.toString());
    public void loadNames(ResultSet rsconsultants)
    //Fill last name list box
    try
    while(rsconsultants.next())
    lstNames.add(rsconsultants.getString("Consultant_Lname"));
    catch (SQLException error)
    System.err.println("Error in Display Record." + "Error: " + error.toString());
    public void itemStateChanged(ItemEvent event)
    //Retrieve and display the selected record
    String strConsultant_Lname = lstNames.getSelectedItem();
    lblMessage.setText(""); //Delete instructions
    try
    rsconsultants = cmdconsultants.executeQuery(
    "SELECT c.Consultant_ID"+
    "c.Consultant_Lname"+
    "c.Consultant_Fname"+
    "c.Title"+
    "l.Client_ID"+
    "l.Client_Name"+
    "l.Address"+
    "l.City"+
    "l.State"+
    "l.Zip"+
    "b.Hours_Billed"+
    "b.Billing_Rate"+
    "b.Client_ID"+
    "b.Consultant_ID"+
    "FROM Consultants c, Clients l, Billing b"+
    "WHERE c.Consultant_ID = b.Consultant_ID"+
    "l.Client_ID = b.Client_ID"+
    "GROUP BY c.Consultant_ID");
    //"SELECT * FROM Consultants INNER JOIN Billing ON Consultants.Consultant_ID = Billing.Consultant_ID");
    //FROM Consultants INNER JOIN Billing ON Consultants.Consultant_ID = Billing.Consultant_ID;");
    //"Select * from consultants where [Consultant_Lname] = '" + strConsultant_Lname + "';");
    txtConsultant_Lname.setText(strConsultant_Lname);
    displayRecord(rsconsultants);
    setTextToEditable();
    catch(SQLException error)
    lblMessage.setText("Error in result set. " + "Error: " + error.toString());
    public void displayRecord(ResultSet rsconsultants)
    //Display the current record
    try
    if(rsconsultants.next())
    txtConsultant_Fname.setText(rsconsultants.getString("Consultant_Fname"));
    txtTitle.setText(rsconsultants.getString("Title"));
    txtHours_Billed.setText(rsconsultants.getString("Hours_Billed"));
    lblMessage.setText("");
    else
    lblMessage.setText("Record not found");
    clearTextFields();
    catch (SQLException error)
    lblMessage.setText("Error: " + error.toString());
    public void actionPerformed(ActionEvent event)
    //Test the command buttons
    Object objSource = event.getSource();
    if(objSource == btnAdd && event.getActionCommand () == "Add")
    Add();
    else if (objSource == btnAdd)
    Save();
    else if(objSource == btnEdit)
    Edit();
    else if(objSource == btnDelete)
    Delete();
    else if(objSource == btnCancel)
    Cancel();
    public void setTextToNotEditable()
    //Lock the text fields
    txtConsultant_Lname.setEditable(false);
    txtConsultant_Fname.setEditable(false);
    txtTitle.setEditable(false);
    txtHours_Billed.setEditable(false);
    public void setTextToEditable()
    //Unlock the text fields
    txtConsultant_Lname.setEditable(true);
    txtConsultant_Fname.setEditable(true);
    txtTitle.setEditable(true);
    txtHours_Billed.setEditable(true);
    public void clearTextFields()
    //Clear the text fields
    txtConsultant_Lname.setText("");
    txtConsultant_Fname.setText("");
    txtTitle.setText("");
    txtHours_Billed.setText("");
    public void Add()
    //Add a new record
    lblMessage.setText(" "); //Clear previous message
    setTextToEditable(); //Unlock the text fields
    clearTextFields(); //Clear text field contents
    txtConsultant_Lname.requestFocus ();
    //Set up the OK and Cancel buttons
    btnAdd.setLabel("OK");
    btnCancel.setEnabled(true);
    //Disable the Delete and Edit buttons
    btnDelete.setEnabled(false);
    btnEdit.setEnabled(false);
    public void Save()
    //Save the new record
    // Activated when the Add button has an "OK" label
    if (txtConsultant_Lname.getText().length ()== 0 || txtTitle.getText().length() == 0)
    lblMessage.setText("The Consultant's Last Name or Title is blank");
    else
    try
    cmdconsultants.executeUpdate("Insert Into consultants "
    + "([Consultant_Lname], [Consultant_Fname], Title, [Hours_Billed]) "
    + "Values('"
    + txtConsultant_Lname.getText() + "', '"
    + txtConsultant_Fname.getText() + "', '"
    + txtTitle.getText() + "', '"
    + txtHours_Billed.getText() + "')");
    //Add to name list
    lstNames.add(txtConsultant_Lname.getText());
    //Reset buttons
    Cancel();
    catch(SQLException error)
    lblMessage.setText("Error: " + error.toString());
    public void Delete()
    //Delete the current record
    int intIndex = lstNames.getSelectedIndex();
    String strConsultant_Lname = lstNames.getSelectedItem();
    if(intIndex == 0) //Make sure a record is selected
    //Position 0 holds a text message
    lblMessage.setText("Please select the record to be deleted");
    else
    //Delete the record from the database
    try
    cmdconsultants.executeUpdate(
    "Delete from consultants where [Consultant_Lname] = '" + strConsultant_Lname + "';");
    clearTextFields(); //Delete from screen
    lstNames.remove(intIndex); //Delete from list
    lblMessage.setText("Record deleted"); //Display message
    catch(SQLException error)
    lblMessage.setText("Error during Delete."
    + "Error: " + error.toString());
    public void Cancel()
    //Enable the Delete and Edit buttons
    btnDelete.setEnabled(true);
    btnEdit.setEnabled(true);
    //Disable the Cancel button
    btnCancel.setEnabled(false);
    //Change caption of button
    btnAdd.setLabel("Add");
    //Clear the text fields and status bar
    clearTextFields();
    lblMessage.setText("");
    public void Edit()
    //Save the modified record
    int intIndex = lstNames.getSelectedIndex();
    if(intIndex == 0) //Make sure a record is selected
    //Position 0 holds a text message
    lblMessage.setText("Please select the record to change");
    else
    String strConsultant_Lname = lstNames.getSelectedItem();
    try
    cmdconsultants.executeUpdate("Update consultants "
    + "Set [Consultant_Lname] = '" + txtConsultant_Lname.getText() + "', "
    + "[Consultant_Fname] = '" + txtConsultant_Fname.getText() + "', "
    + "Title = '" + txtTitle.getText() + "', "
    + "[Hours_Billed] = '" + txtHours_Billed.getText() + "' "
    + "Where [Consultant_Lname] = '" + strConsultant_Lname + "';");
    if (!strConsultant_Lname.equals(txtConsultant_Lname.getText()))
    //Last name changed; change the list
    lstNames.remove(intIndex); //Remove the old entry
    lstNames.add(txtConsultant_Lname.getText()); //Add the new entry
    catch(SQLException error)
    lblMessage.setText("Error during Edit. " + "Error: " + error.toString());
    public void stop()
    //Terminate the connection
    try
    if (conconsultants != null)
    conconsultants.close();
    catch(SQLException error)
    lblMessage.setText("Unable to disconnect");

    If you look at this web page at some of the other options, they may give you a clue on how to setup the Netgear.
    Wireless connection problems
    The main thing is to ensure that you give the two access points, fixed IP addresses outside of the DHCP range of the home hub.
    Try 192.168.1.15  and 192.168.1.16
    The Netgears probably are on the wrong IP subnet at the moment, so they will not work.
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

Maybe you are looking for