Help In Programming Needed.

This is part of a program written in JSP using netbean.
<%
try {
String driver = "com.mysql.jdbc.Driver";
String database = "jdbc:mysql://localhost/crm";
Class.forName(driver);
System.out.println("Driver " + driver + " loaded.");
Connection connection = DriverManager.getConnection(database, "root", "123");
System.out.println("Database " + database + " loaded.");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT PASSWORD FROM USER WHERE STAFFID = \'" + logUser.getSTAFFID() + "\'");
resultSet.next();
if (logUser.getPASSWORD().equals(resultSet.getString(1))) {%>
<jsp:forward page="HomeLogIn.jsp" />
<% } else {%>
<jsp:forward page="LogInError.jsp" />
<% }
} catch (Exception ex) {
ex.printStackTrace();
} %>
And this is error that was produced when try to run it.
java.sql.SQLException: Illegal operation on empty result set.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:713)
at com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:5624)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5544)
at org.apache.jsp.Home_jsp._jspService(Home_jsp.java from :88)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Can anyone tell me what's wrong with my program?

If you take a glance at the [API for ResultSet|http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html#next()] you might notice that the rs.next() method returns a boolen value.
It returns true if there IS a next record, otherwise false.
Most people write code something like
if (rs.next()){
  // if only one result is expected
//or
while(rs.next()){
  // if multiple rows are expected.
}

Similar Messages

  • My first java programming - Need some help please!!!

    I have to create a simple java program which i am not good at i am ok in C but my java is quite bad. The program need to define a class called Student and with a string called StudentNAme, a integer StudentID(key), An array of 8 integers called Marks that holds the students marks for 8 modules. It also says Include appropriate accessors, mutators and constructor(s) as well as a method to update the student�s marks. Anybody please help me in this question. I prefer an simple example of this program so I can learn faster, I dont even know how to declare a class.. So sorry but please help me out and thanks in advance

    I would also suggest you try using an IDE like
    eclipse (free)
    www.eclipse.org
    This will help you get a working program much faster.But please do also tell them that if they have troubles using it, they're supposed to read the IDE manual instead of posting here.

  • I purchased Acrobat Standard, not realizing it is not compatible with MAC. I need to exchange. I just chatted with a so-called "specialist" who told me to sign in and download the same program. I got the same blasted message. I need help. I need to exchan

    I purchased Acrobat Standard, not realizing it is not compatible with MAC. I need to exchange. I just chatted with a so-called "specialist" who told me to sign in and download the same program. I got the same blasted message. I need help. I need to exchange this program for one that is compatible with my MAC. The standard is of no use to me at all. I feel like I have been ripped off

    Hi Kargi,
    We are working on getting things straightened out for you. You should be hearing from a Customer Care agent shortly.
    Best,
    Sara

  • Urgent please help, this program should work

    Urgent please help.
    I need to solve or I will be in big trouble.
    This program works at my home computer which is not networked.
    The hard disk was put onto another computer at another location whihc is networked. Here my program worked on Monday 14 october but since for the last two days it is not working without me changing any code. Why do I receive this error message???
    Error: 500
    Location: /myJSPs/jsp/portal-project2/processviewfiles_dir.jsp
    Internal Servlet Error:
    javax.servlet.ServletException
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
    at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:162)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java:235)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
    at java.lang.Thread.run(Thread.java:536)
    Root cause:
    java.lang.NullPointerException
    at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:132)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java:235)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
    at java.lang.Thread.run(Thread.java:536)

    foolishmatt,
    The code is quit large.
    to understand the program I think all the code needs to be examined.
    I would need to send to you in an email.
    Here is my e-mail
    [email protected]
    if you contact me than I can send the code to you.
    Thank you in advance.

  • Adding the search help in program

    hi i want to add a search help in program for a particular field of a parameter how to do this?

    U need to create a serach help exit for this purpose.
    F4IF_SHLP_EXIT_EXAMPLE - documents the different reasons to use a search help exit, and shows how it is done.
    http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_exit.htm
    http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_basic.htm
    Create an Elementary Search help:
    Eg: Zsearch
    In the defintion tab:
    Give the search help exit name: Zsearch_exit.
    Also give the search help param and data element.
    Copy F4IF_SHLP_EXIT_EXAMPLE into Zsearch_exit
    Comment:
    callcontrol-step = 'SELECT'.  (1st line)
    Inside:
      IF CALLCONTROL-STEP = 'SELECT'.
    Select required data for the search help
    Select stmnts as per your requirement and populate in itab.
    Move all the selected records to Record_Tab
        LOOP AT itab INTO wa_itab.
          MOVE wa_itab TO record_tab-string.
          APPEND record_tab.
          CLEAR record_tab.
        ENDLOOP.
        RC = 0 .
        IF RC = 0.
          CALLCONTROL-STEP = 'DISP'.
        ELSE.
          CALLCONTROL-STEP = 'EXIT'.
        ENDIF.
        EXIT. "Don't process STEP DISP additionally in this call.
    Let me know if its working for you.
    Also, chek this link if it helps you:Re: Find Storage location with respect to Plant

  • Search help freely programmed

    Hi all,
    is anyone able to explain me how to use Search Help freely programmed?
    thanks
    GN

    Hi Gabriele,
    Please go through the component DEMO_VALUE_HELP. This explains all the input help types. The freely programmed search help has been implemented for the CONNID input field of view V1. The Web Dynpro component FREE_VALUE_HELP in the same package is the component where the search help is coded.
    Also below are the steps to be followed for implementing the freely programmed search help.
    This kind of value help is implemented as a Web Dynpro component implementing the Web Dynpro
    component interface IWD_VALUE_HELP. To be able to use the value help for a certain input field, the following steps are necessary:
    1) A component usage of the value help component (HC) has to be declared
    by the consumer component (CC).
    2) A usage of the HC interface controller has to be declared in the CC view.
    3) The input help mode User-Defined Programming has to be chosen for the attribute that is bound to the input field under consideration. The HC usage must be related to this attribute. The component interface of the HC has only one method: set_value_help_listener( ). This method is called by the Web Dynpro runtime if the value help button of the input field under consideration is clicked. The HC has to be implemented as follows:
    1) The method set_value_help_listener( ) has an import parameter. This means that the reference to the listener, provided by the Web Dynpro runtime, is passed to the user-defined HC. This reference has to be saved as a user defined controller attribute.
    2)  To close the help value dialog box, the close_window( ) method of the listener has to be used.
    3)  All views have to be embedded into a window having the name WD_VALUE_HELP. This name is used by the Web Dynpro runtime.
    4) To exchange data between the CC and the HC, context mapping can be used.
    For implementing the component interface IWD_VALUE_HELP, you need to choose the Reimplement button in the HC. The implementation status changes to green and the events and the method of the component interface are visible in the HC controller.
    Regards,
    Uday

  • HELP!!Need to import and print vector drawings

    I am trying this topic again in the hope of help. I need to
    import drawings in a vector format for printing. These drawings
    will be cast members not sprites. I have tried printing a swf
    version via Printomatic but it cannot print Flash members. My
    questions are:
    1. Is therre any way to print a swf cast member (not a
    sprite)
    2. How can I import an EPS file? - I have heard that it can
    be done but every version I have tried seems to fail

    Darrel Plant has written an importer for .ai and .eps files.
    You can get
    it at:
    http://www.moshplant.com/direct-or/ps2vs/
    Haven't used it for a while but it works pretty good.
    Downside is that it creates multiple members because Director
    can't
    (couldn't?) handle multiple-line vector members.
    Dsotm wrote:
    > I am trying this topic again in the hope of help. I need
    to import drawings in
    > a vector format for printing. These drawings will be
    cast members not sprites.
    > I have tried printing a swf version via Printomatic but
    it cannot print Flash
    > members. My questions are:
    > 1. Is therre any way to print a swf cast member (not a
    sprite)
    > 2. How can I import an EPS file? - I have heard that it
    can be done but every
    > version I have tried seems to fail
    >
    Manno Bult
    [email protected]

  • If i reset my ipad can i install paye games for free if i sign back into my apple ID. Please i need help because i need to update my games but i need to put in this billing thing and i want to get rid of it so then i cant buy games with my credit card

    If i reset my ipad can i install paye games for free if i sign back into my apple ID. Please i need help because i need to update my games but i need to put in this billing thing and i want to get rid of it so then i cant buy games with my credit card

    Hello,
    As frustrating as it seems, your best to post any frustrations about the iPhone in the  iPhone discussion here:
    https://discussions.apple.com/community/iphone/using_iphone
    As this discussion is for iBook laptops.
    Best of Luck.

  • Hi! I can't upgrade my iTunes 10.3.1.55 on my Windows XP 2002 SP3 to the latest version of iTunes. Got the message: "A problem has occured with the Windows Installer-package. A program needed for this installation could not be run." What to do?

    Hi! I can't upgrade my iTunes 10.3.1.55 on my Windows XP 2002 SP3 to the latest version of iTunes. Got the message: "A problem has occured with the Windows Installer-package. A program needed for this installation could not be run." What to do?

    Perhaps let's first try updating your Apple Software Update.
    Launch Apple Software Update ("Start > All Programs > Apple Software Update"). Does it launch and offer you a newer version of Apple Software Update? If so, choose to install just that update to Apple Software Update. (Deselect any other software offered at the same time.)
    If the ASU update goes through okay, try another iTunes install. Does it go through without the errors this time?

  • I have an iphone 4 and it won't let me download nothing! Help me I need my phone apps!

    I have an iphone 4 and it won't let me download nothing! Help me I need my phone apps!

    Vague.
    Please explain

  • Can somebody please tell me how to fix this. when i try to install appleworks this pops up  so please help me i need to get this on my mac

    can somebody please tell me how to fix this. when i try to install appleworks this pops up
    so please help me i need to get this on my mac

    AppleWorks is a very old application and requires Rosetta to run under recent systems.
    Lion does not include Rosetta.
    If you browse this forum you will find many posts on this issue.

  • In iTunes the iPhone device icon will not show up whenever I plug in a USB into my PC but the iPhone icon will show up in 'This PC'  so if anyone who knows a resolution to my problem with my iTunes or PC,it would really help me.I need at least Help or Tip

    In iTunes the iPhone device icon will not show up whenever I plug in a USB into my PC but the iPhone icon will show up in 'This PC'  so if anyone who knows a resolution to my problem with my iTunes or PC,it would really help me.I need at least Help or some Tips.I have already tried many things to iTunes and my PC like trying to restore my PC but that do anything.Also,would it be fine if i contacted (call) Apple Support? Please,I need help because what I think is wrong is my PC,iPhone,or USB might be messed up so if anyone could help me with this,it would be really helpful and for anyone to be nice enough to help me.

    I think this article will help you.

  • HT4199 I just got a new iPod touch 4th generation and I'm trying to connect to my router and my iPod says, 'Cannont find network.' I don't know what to do! No other networks come up on the list so I can't 'tag' along with thier wifi. Please help. I need a

    I just got a new iPod touch 4th generation and I'm trying to connect to my router and my iPod says, 'Cannont find network.' I don't know what to do! No other networks come up on the list so I can't 'tag' along with thier wifi. Please help. I need advice.

    What type network is yu router set up for? The 4G iPod can only connect and see 2.4 GHZ networl like B, G and the 2,4 GHz N. There is also a 5 GHz N but the iPod will not even seethat network.
    See:
    iOS: Troubleshooting Wi-Fi networks and connections
    iOS: Recommended settings for Wi-Fi routers and access points

  • External hard drives no longer working in Mavericks - HELP!  I need my data...

    Hello
    I recently upgraded to Mavericks (10.9.2) and this morning I was trying to find some files so connected my external hard drive (back-up 1).  Light went on...nobody home.  The drive didn't register as it had done last week.  In my hurried state I plugged in external hard drive 2 (back-up 2) and the same thing happened.
    Not phased by this I took my hard drives to work and tried them in my PC and also a friend's mac (not upgraded).
    Annoyingly I cannot access anything, in fact they don't even register existence even though they are whirring with the lights on.
    Please help! I need my data

    Hello AstroTravel,
    Thank you for the details of the issue you are experiencing with your external hard drive.  I found an article with steps you can take when an external device is not being recognized.
    I recommend following the steps in the section titled "Top troubleshooting tips" in the following article:
    USB and FireWire Quick Assist
    http://support.apple.com/kb/HT1151
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • TS2446 my app store is not working, i tired signing in but showing me "An unknown error has occurred" my password is not wrong, please and someone help, because i need to update my macbook air. thank you

    my app store is not working, i tired signing in but showing me "An unknown error has occurred" my password is not wrong, please and someone help, because i need to update my macbook air. thank you... how can i make it work?

    I cannot sign out. When I go to the iTunes & App Stores in settings, The Apple ID field shows my id but it is faded and I cannot select the field.

Maybe you are looking for