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>

Similar Messages

  • Access database query data in Java SCriptlet

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    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:
    *** 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");
    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:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    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:
    *** 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");
    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:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

  • How to create a ms-access database at runtime using java

    hi, this is ravi kiran,
    i have a situation where i need to create a new ms-access database with one table in it at runtime(when user clicks on some button).
    i have been searching many sites to know how to do this in java, but i didnot find any thing useful.
    plz tell me how to do this in java.
    plz help me, its urgent
    thanx in advance.

    Here's how I did it. Research does help, but sometimes looking at others code does too... You do have to have a dummy file that you made with access though. You can't just make a file file.mdb (it will be corrupt)
         public void createDatabase(String database) throws SQLException{
              try{
                   // This file needs to have been created with MS Access
                   File dbfile = new File(this.dataBaseDir + "dummy.mdb");
                   // This is the new database file being made
                   File newFile = new File(this.dataBaseDir + database + ".mdb");
                   // Copy all bytes from dummy file to new DB file.
                   FileInputStream instream = new FileInputStream(dbfile);
                   FileOutputStream ostream = new FileOutputStream(newFile);
                   int numBytes = instream.available();
                   byte inBytes[] = new byte[numBytes];
                   instream.read(inBytes, 0, numBytes);
                   ostream.write(inBytes, 0, numBytes);
              catch(FileNotFoundException e) { e.printStackTrace();}
              catch(IOException e) { e.printStackTrace();}
              if(DEBUG) System.out.println("creating the " + database + " database");
         }

  • How to access MS ACCESS database from Solaris running Java application

    Hello I have a reqmt
    My Java application is running on Weblogic server on Solaris 2.7 and now I want to connect to MS Access database running on Win NT.
    How do I do that??
    Any help is appreciated
    Thanks
    Suresh

    You have to use a proxy server and client.
    You can search for commercial solutions via the sun jdbc site or use RmiJdbc at http://www.objectweb.org/

  • How to know MS Access Database is down through Java

    How i would know whether MS Access DataBase is down?
    Is there any specific code for it in Java
    Need a quick reply

    How i would know whether MS Access DataBase is down?"down"? If the file system on which it's running is unavailable, that's the best you can do. If you can't connect, it's "down".
    Is there any specific code for it in JavaNo. Doesn't sound very platform-independent.
    Need a quick replyFast enough?
    %

  • Access BEx Query resultset Clientside

    How can we manipulate the output of a bex query client side (internet explorer).
    We have an output of a query which we would like change before data is exported to excel.
    Can we somehow access and change the query resultset client side with e.g.. JavaScript ? Is the resultset stored in an accessible object (clientside).
    Thx

    I don't have any experience but for someone with good Javascript skills, you can access the Analysis table using xpath expressions. This blog might get you started:
    /people/prakash.darji/blog/2006/09/22/using-xpath-statements-within-sap-netweaver-2004s-bex-web-application-designer--part-1

  • Access database query import

    I have some queries stored in databases from MS Access which I am trying to import into DIAdem.  I use the open with option for the database to select the query I wish to load and then chose selective opening to grab the columns of data I really want.  It appears to import the data but only the first 27890 entries - the total is approx 750,000.  Why is only about 27890 entries being imported?

    Hi Jim,
    No, I am not sure why you are experiencing this difference in load behavior.  We tried to replicate your situation here and were able to successfully load either by selecting the whole table or specific columns within that table:
    ACCESS Table with 7 columns, each column with 560 000 values
    Tested on both a DIAdem 9.1 SP2c computer and a DIAdem 10.1 SP1 computer (clean installs)
    Result in DIAdem:
    7 channels, each channel with 560 000 values if I load the table complete
    3 channels, each channel with 560 000 values if I load selected channels
    The first step is for us to reproduce your symptoms.  Would it be possible for you to post your Access database on our ftp.ni.com/incoming server?
    How much RAM do you have on your computer?
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Access Database Query

    I am running a query on an access database, but am getting some strange results. The problem might be access and not Visual studio though.
    Here is the core of the problem:
    If I run the following query, I get exactly what I want
    SELECT ID, Question, Solved, Date_Created, Date_Last_Edit, Date_Closed
    FROM(
    SELECT F.ID AS Ident, Count(F.ID) AS Num
    FROM(
    SELECT Keywords, ID, Question, Solved, Date_Created, Date_Last_Edit, Date_Closed
    FROM(
    SELECT ID, Solved, Date_Created, Date_Closed, Date_Last_Edit, Question, Model, Keywords.Value AS Y FROM Questions) AS X INNER JOIN Keywords ON X.Y =Keywords.ID
    Where Keywords = "Back" ) As F
    Group By F.ID
    HAVING (((Count(F.ID)) =1)))
    As T Inner Join Questions
    On T.Ident = Questions.ID
    But, if I change
    Where Keywords = "Back"
    to
    Where Keywords Like "*Ba*"
    I get nothing from my query. No errors, just no data.
    The strange thing is, if I output my query to a message box, and copy and paste it into access and run the query, it runs just fine. I've double checked all the syntax and I don't get a syntax error back from the code anyway.

    Hi Mynamewasused,
    Thank you for posting in MSDN forum.
    Since this forum is to discuss: Visual Studio WPF/SL Designer, Visual Studio Guidance Automation
    Toolkit, Developer Documentation and Help System, and Visual Studio Editor.
    To help you find the correct forum support this issue, could you please tell me if you running a query on an access database with ADO.NET?
    Best Regards,
    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.

  • Database query ResultSet from servlet to JSP page

              Hi there,
              I have an Access 2000 database. I am running Apache and Tomcat on Windows Me.
              I would like to know if it is possible for me to use a Servlet to search the
              database (I know this bit is possible!), but then I would like the servlet to
              forward to a jsp page which will then display the ResultSet that the servlet has
              retrieved, i.e. when forwarding from a servlet to a jsp, is it possible for the
              jsp page to have access to the servlet's data? I know that it gets access to
              the response and request objects, but what about a ResultSet?
              Sorry it this sounds a little silly - i am a bit of a newbie.
              Thanks in advance for your help,
              SJ
              

    HttpServletRequest.setAttribute let's you share data for a particular
              request. When you call forward you can store the resultset in the request.
              Make sure your JSP does close the result set though, because what you are
              trying to do doesn't sound good :)
              If you want to share data across the session, take a look at the HttpSession
              object.
              read through the servlet specification, it is fairly easy to read and will
              give you all the info you need
              Filip
              ~
              Namaste - I bow to the divine in you
              ~
              Filip Hanik
              Software Architect
              [email protected]
              www.filip.net
              "SJ" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi there,
              >
              > I have an Access 2000 database. I am running Apache and Tomcat on Windows
              Me.
              > I would like to know if it is possible for me to use a Servlet to search
              the
              > database (I know this bit is possible!), but then I would like the servlet
              to
              > forward to a jsp page which will then display the ResultSet that the
              servlet has
              > retrieved, i.e. when forwarding from a servlet to a jsp, is it possible
              for the
              > jsp page to have access to the servlet's data? I know that it gets access
              to
              > the response and request objects, but what about a ResultSet?
              >
              > Sorry it this sounds a little silly - i am a bit of a newbie.
              >
              > Thanks in advance for your help,
              >
              > SJ
              

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

  • Inserting into MS Access Database - Wierd resultset!!

    I'm developing an application that takes in values from t1 in the database, performs operations on them and inserts them into t2. For this I have to check all records in t2 every time I'm about to make an insertion.. Strangely enough, rs1.beforeFirst() (rs1 is the resultset for t2) in my code refuses to put the cursor before the 1st row, and the code continues operations from the last row..Help!!
    Here's a sample of my code:
    rs1.beforeFirst();
                   if(rs1.next())
                        do
                             if(rs1.getInt("uid")!=i)
                             {     rs1.next();     }
                             else
                             {     break;
                        }while(!rs1.last());
                        if(rs1.isAfterLast())
                        {     n=1;
                             s1="Insert into t_urlinfo values('" + dt + "'," + i + ",'" + text + "'," + n + ")";
                             System.out.println(s1);
                             stmt2.executeUpdate(s1);
                        }

    Where, in that code, are you calling beforeFirst?
    Also, why do you feel it necessary to "check every row" before an insert? Is it to avoid duplicates? If so, does your table have a primary key or other unique field? If so, simply attempt to insert and then catch the SQLException.

  • Replication of MS Access database

    Is this possible to replicate an MS Access database (.mdb) file using Java?.
    I want to do this either in JSP or Servlet.
    Please provide any resource links.
    This is quite urgent.
    Thanks in advance.

    please don't cross-post
    http://forum.java.sun.com/thread.jsp?forum=54&thread=344531
    do you want to make a copy of an Access database? Or do you want to synchronize two (or more) databases? Either way, if your options are JSP or Servlet (pretty much the same things, really), use a straight servlet, no need to throw in HTML. As for the actual mechanics of your replication, it depends on what you want to do.
    Lee

  • Can Java Query An Access Database?

    Is it possible to write a Java program that can retrieve data from Microsoft Access tables? If so, how is this accomplished? Are there any tutorials on the subject?

    I am not sure about the exact specifics, but what you can do is set up a JDBC-ODBC bridge. What that means is you set up an ODBC DSN for your access database. Then you use sun's jdbcodbc driver to access that ODBC DSN, and they execute normal SQL against that...
    Hope that gets you started!
    ERic

  • Query a resultset in java like CFQUERY

    Hello,
    Is there a way to query a resultset in java. Yes what I mean is after obtaining one resultset, again query on that resultset like we do to a table in the DB.
    Here is my problem in detail and any help doing the same in Java will be most appreciated :-)
    I am working on a peculiar problem where we are moving our application from cold fusion to Java. Cold fusion being very powerful for database oriented applications my project was initially developed using CF and uses a lot of advanced features of CF. However the need to move to java was soon realised due to various reasons. Now one of the main problems we are facing is the CFQUERY tag in cold fusion.
    This tag lets you create a resultset by
    <cfquery name="aaa" datasource="blah-blah">
    QUERY COMES HERE
    </cfquery>
    The best part is.... you can also query the above resultset obtained as follows:
    <cfquery name="bbb" dbtype="query">
    SELECT * from aaa where ***************
    </cfquery>
    We have used it so often in CF since it significantly reduces the query throughput times. Now we would love to find a way to do the same in Java.
    Any ideas
    Thanks
    Karen

    Yes thats one way of working with it. But the problem
    is we are dealing with very huge volume of data and
    hence querying an already existing resultset is the
    best option and has been working very well with our
    kind of project too. We also have several concurrent
    users doing the same which adds more load on the DB so
    doing it from the CF/Java end seems a better choice
    for us.I understand your sentiment, but having worked with applications trying to 'port' applications to new technologies I would have some concerns with your approach. Rather then 'port' the application I would suggest that you will have to re-engineer the application. This is more true for larger systems where larger system is heavy mulit-user, or large database access. It is also more true for applications moving from procedural to object based languages.
    I don't agree that you are better off manipulating data on the application server. In my experience I have found that data manipulation is optimized when running as close to the database as possible (for the reasons listed in my previous post). So if you decide to re-engineer you may want to consider this in your design decisions.
    We already have the DB so we are not even considering
    looking for another one. BTW we're using SQL SERVER.Well, as long as you don't have too many users (darn that original sybase lock manager) :-)
    I too can't think of a way to get this done using Java
    like CF. Hmmm .... yeah if nothing else then we'll
    have to change the way we work all together.I have no experience in using it, but user "cluckcluck" posted the following. Might be something to take a look at. This is similar to what I was talking about when using embedded Java databases like Cloudscape, but this works with external databases:
    "An excellent solution for this sort of problem is Hibernate (www.hibernate.org) a DB independent ORM persistance layer. Each data source would need to be defined, and each datasource would have its own SessionFactory but once this mapping and config is done you can treat the contents of the DB as POJOs, and perform queries against them. Its not so generic that you wouldn't still have to know which data model the entity you are after is in..."
    Good Luck!

  • Java, access database( mdb) and java.sql.date

    I having a problem querying my access database with user specified date the code is as follows
    //get results of income from database with respectto dates
         //so u first create the sql.date instances
         private void getResults(){
         String text1=from.getText();//text input is like this 01-01-2005
              String text2=to.getText();
         Date d1=new Date(Integer.parseInt(text1.substring(6)),Integer.parseInt(text1.substring(3,5)),Integer.parseInt(text1.substring(0,2)));
         JOptionPane.showMessageDialog(this,d1.toString());//traces date with 1900 added to year and 1 added to month
         try{
              //custom class DataSource used to connect to database
              Connection conn=DataSource.getConnection("RealFotoInc");
              PreparedStatement ps=conn.prepareStatement("select * from Members where date=?");
              ps.setDate(1,d1);
              ResultSet rs=ps.executeQuery();
              while(rs.next()){
                   System.out.println("going");
                   System.out.println("trial"+rs.getString(3));
         }catch(Exception se){
              JOptionPane.showMessageDialog(this,se);
         }and it prints out nothing I dont know what is wrong

    Whoever put that comment in there about "1900" and so on knew what had to be done. That "Date" class must be "java.sql.Date"; go and read the API documentation of that constructor you are using there. Then adjust the parameters you are passing to it accordingly.

Maybe you are looking for

  • Crash:  Acrobat X Standard, 10.1.5

    Crash occurs upon simply selecting, cutting, or pasting a pdf file (with or without the preview pane open) in Windows Explorer.  Upon double click, the file opens fine.  However I recieve about 15 of these per day.  Crash started upon install of 10.1

  • Wrt54gs needs to be powercyled

    Hi i have a wrt54gs v 6. Every couple of hours, or sometimes days, i have to powercycle the router  in order to have an ip adress assigned. Also i have found that the router setup page deteorates till the point that my request times out. I have also

  • My Ipod & Itunes doing  lots of weird things - not just one

    Since upgrading to 7.2 my ipod tries to sync, but can't, itunes works for a minute and then freezes up, then gets unstuck, then freezes up, again, it won't recognize CD titles and lables, it won't import, I can't delete songs or audiobooks, it downlo

  • Intra company STO repair

    Hello All, Please inform what is the best way to handle the intra company STO repair material. STO with SD delivery is done from plant 10 to plant 30 and few materials are needed to send back to plant 10 (supplying plant) for repair due to quality pr

  • Not seeing all letters in dynamic text fields

    I think that I have properly embedded the Verdana font (see image below).  However, in my Flash game, dynamic text fields do not show certain letters, such as X and J.  What am I missing?  Is there a safer font that I should be using besides Verdana?