Select Max and ResultSet Problem With Access

The following code is producing a 'null pointer excepetion' error and I know why it is occurring I just do not know how to fix the problem.
Basically I want to automitically generate a unique ID that is one number higher than the max ID (data is stored within an Access database). The ID field is made up of first and last initial taken from parsing previous login info ('JS-01', 'JS-02', ect.). If there are no IDs in the database that match your login info I want to set the new ID equal to 'JS-01' if your login is 'James Smith' for example.
The problem is explained within the code below.
<%
//define resultset and statement
ResultSet rss=null;
ResultSet rs=null;
Statement stmt=null;
//HERE IS WHERE YOU PARSE THE LOGIN INFO
String finitial = (String)session.getAttribute("vfirst");//vfirst=JIM
String linitial = (String)session.getAttribute("vlast");//vlast=SMITH
char f = finitial.charAt(0);
char n = linitial.charAt(0);
String sID = f+""+n;//NOW sID CONTAINS 'JS'
try {
//Using the current database connection create a statement
stmt=con.createStatement();
//QUERY TO SELECT MAX ID
//NOTE: CURRENTLY THERE ARE NO IDs LIKE 'JS' IN THE DATABASE !!!!!!
String sql="SELECT Max(ID) As MaxID FROM tblError Where ID LIKE '%"+sID+"%'" ;
rs = stmt.executeQuery(sql);
String newID;
//HERE THE RESULT SET SHOULD BE NULL BUT IT IS NOT. I KNOW THIS BECAUSE WHEN I REPLACE String iID WITH A LITERAL LIKE 'JS-03' THE LOGIC WILL EXECUTE CORRECTLY AND GIVE ME 'JS-04'. IF I LEAVE THE CODE LIKE IT IS THEN I GET THE NULL POINTER VALUE ERROR BECAUSE YOU CANNOT RESOLVE "MaxID" WHEN THE RESULT SET IS NULL. IF THE RESULT SET IS NULL IT SHOULD NOT EVEN EXECUTE ANY OF THIS CODE WITHIN THE 'if' STATEMENT, BUT IT IS. SO BASICALLY JSP IS LEAVING ME WITH A MAJOR OXYMORON AND I WOULD APPRECIATE ANY ADVICE THAT WOULD HELP ME SOLVE THIS PROBLEM.
if(rs.next()){
String iID = rs.getString("MaxID");
String letters = iID.substring(0,3);
int numbers = Integer.parseInt(iID.substring(3,5));
numbers = numbers + 1;
if(numbers < 10){
newID = letters + "0" + numbers;}
else{
newID = letters + numbers;
else{//IF THERE IS NO RESULT SET THAN THE ID SHOULD BE 'JS-01'
newID = sID + "-01";
%>
Because this an Access database I cannot use any null exception functions such as NVL or COALESCE which are specific to Oracle and SQL Server I beleive.

The max() will return a result set, even if the max value is null.
You should check to see if iID is null.
if(rs.next())
   String iID = rs.getString("MaxID");
   if (iID == null)
       newID = sID + "-01";
   else
      String letters = iID.substring(0,3);
      ... etc ...
}

Similar Messages

  • T60p & Windows 7 Pro and Bluethoot problem with Access Connections.

    Hi,
    I reinstalled Windows 7 Pro (64bit) at my T60p laptop.
    I use Access Connections (v. 5.97) manage my wi-fi, lan connections.
    (installed with all features lan, wi-fi, modem etc.)
    So here is problem.
    When I start Access Connection. Bluethoot goes ON ...
    Trying disable Bluetooth via Access connectios (Power Off), but it's still going "ON" and stays "ON"...
    Any good solution to keep bluethoot off without disable it at bios?
    Earlier version of Access Connections keeps bluetooth OFF...
    /P

    If you are not using the Bluetooth and you want to disable it, the easiest way is to disable the device in the Device Manager.
    Go into the Device Manager by searching for Device Manager in the start menu, Open the Device Manager and select hardware, choose the Bluetooth device, right click, and finally choose 'disable'. If you want to use the Bluetooth device in the future you will have to return to the Device manager, right click and 'enable' the device.
    I hope this information has been helpful, please let me know if you have any further questions.
    Thank you for being a part of the Lenovo Family,
    Catie
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Donate KUDOS and Click "Accepted Solution"

  • Access Web Database - Select record and make report with all associated records

    Hey everyone,
    Right now I'm in the middle of trying to convert an Access client database to be web compatible and I'm running into some problems. For this question, I think I may need to explain a little bit about the database:
    The database I'm making is designed to store information about music rights for different songs. The users can input information about writers, producers, organizations, properties, businesses - which is stored all in different related tables. Then, when a
    user inputs a song, they choose which writers, produces, organizations, etc. are affiliated with that song. 
    What I'm trying to do is make a report where you can choose a writer from the list of all the writers and then produce a report with all of the songs by that writer. 
    I was able to do this in the Access client by making a report that, when opened would trigger (using the On Open event) a form to open where you would choose a writer from a combo box and then click a button. When the button was clicked, it would use the value
    in the combo box in a query, which would find all of the songs by that writer and then open up the report which would have the writer and all of their songs on it. 
    Because web reports don't have many event options and web queries are very limited, I have not found a way to make this report.
    Any help at all would be greatly appreciated!

    Hi,
    I found that you've cross post the quesion on our Answer forum, are you satisfiled the reply from there?
    http://answers.microsoft.com/en-us/office/forum/office_2010-access/web-database-select-record-and-make-report-with/04ce4e25-a964-4146-9a34-f9cb26bb0496
    Regards,
    George Zhao
    TechNet Community Support

  • Why do i have a problem with accessing images in adobe muse

    why do i have a problem with accessing images in adobe muse ??????!!!!!
    i need heeeeeelp ASAP
    pleeeeease

    I am on the begining stages with constructing the web so i do not have yet URL. The problem is i can not insert any image any way. Whether by fill a browser or by place image, i have the same issue. All the images with all image's format unable to be selected and it is turned off
    I really need help plz
    Is there any info i can supply that would help you figiring out the problem ??

  • Mail and iPhoto Problems with sending photos.

    Mail and iPhoto Problems with sending photos.
    I have this problem that started a while ago and seems to be getting worse.
    Here are the different scenarios.
    -If I try to share a photo to email within iPhoto, it will insert the image file name in the mail message, but no image icon or opened image. In iPhoto Preferences under General I have chosen to use Email Photos using Mail.
    -If I choose to use iPhoto to send the photo, it will compose the message and the photo is viewable. If I send the message i can view the photo within the email I sent to myself. Nothing happens when I double click on the photo in the Mail message. Nothing happens when i control click on the photo in the mail message. Nothing happens when I try to drag the photo to the desktop from the mail message. When I try to save attachments from the email and choose a place to save it, the save button is grayed out and it cannot be saved. When I check the mail message it says there is an attachemnt but there is no file size listed.
    -If I use the stationary within Mail app I cannot drag a photo into the placeholder, I get a circle with a line through it symbol when I try. It happens if I try to drag a photo from the desktop or from the media browser within Mail app.
    -If I drag the photo to the desktop from iPhoto, I can double click it on the desktop and it will open in Preview.
    -If I then control click on the same photo on the desktop and scroll to share/email, the generic photo icon will be inserted in the mail message. If i double click the photo icon in the mail message  I get a message it can't be opened because it is empty.
    -If I drag that same image to the mail message body the same thing happens.
    -If I send that email to someone they cannot open the image file.
    What I can do:
    - I can drag that same image file on the desktop to my dropbox folder and  it will upload. From there I can go on my iPad and download the photo and send it through email just fine.
    -I can open the same image file on my desktop in Preview, I can copy and paste it into a mail message and the image will be viewable in the mail message by me and by the recipient.
    -I can drag that same image on the desktop to my safari browser window and it will be viewable in the page. i can then copy and paste that image into a mail message and it is viewable in the message.  I can then send that email message to myself and i can control click on the image and get all my options. It also shows as an attachment with the size of the image file in the mail message.
    I can send that message to someone and they can see the photo and open it fine.
    -If I send that same email to me I can see the photo within the mail.  If I then drag that photo to the desktop I cannot use it again to put in an email as the same problem happens again.
    I have tried all scenarios in my user account, another users account and in a guest account. The same happens in all. I am guessing because of this it is not a corrupt preference file, unless all of the preference files are corrupt. The guest user account I added a new email account so it was brand new and still had the problem.
    I am stumped, all and any help is appreciated.

    Another problem that may be related….
    I have Snapz Pro. I used to be able to save the snaps to my desktop or a folder. Now when I take a screenshot and try to save the file to my desktop or a folder on my desktop I get this message  "Files cannot be created in the selected location. You do not have permission to write to the selected location.   Please choose a different location."  I have found that i can only save the file to the clipboard.   I have repaired permissions many times and still I have this problem.

  • Problem with Access Policies (create multiple resources)

    I'm having a problem with Access Policies:
    The first policy must create a resource.
    And the following policies should create childs on the resource.
    The problem here is that when policies will add the childs, the resource is not provisioned yet.
    And then each one will create a resource but i just want one resource with the childs.
    When the resource is already provisioned, the policies update this resource properly.
    How can I fix this?
    tks

    Ricardo,
    I had a similar problem. In a post-process handler I was managing the user membership in specific roles through the removeMemberUser and the addMemberUser of the tcGroupOperationsIntf class.
    The last parameter of this method was a boolean which, when true, would automatically trigger the access policies programmatically in the post-process.
    The problem is that there also is an OOTB event handler for triggering access policies, so I was basically triggering the access policies twice and duplicated resources were appearing.
    Hope this helps.
    Cheers

  • Problem with access to SMTP, IMAP, POP3 protocols in CAS 2013.

    Hi,
    we have problem with access thgrough SMTP, IMAP, POP3 protocols in CAS 2013.
    If I test connection to SMTP 25 port from other computer, session end quickly.
    Test from CAS2013 to localhost or public IP is OK (similar also for IMAP and POP3).
    Receive connectors are with defaults settings, firewall is disabled.
    Service Microsoft Frontend Transport Services restarted, but no success.
    Certificate is assigned to IMAP, POP3, SMTP, IIS.
    IIS and HTTP(s), protocols are OK. Clients can connects only thgrough web, mobile (ActiveSync), or with Outlook with proxy.
    Do you have some tip, what to test?
    If I create new testing receive connector on port 26 for anonymous, behaviour is same, quick disconnecting.
    Thank's Mirek

    Hi,
    Pleaser try to use the following link to test your STMP/POP/IMAP e-mail, and check the test if successful:
    https://testconnectivity.microsoft.com/
    If unsuccessful, please check the test result, it will tell us what caused the problem.
    Thanks.
    Niko Cheng
    TechNet Community Support

  • Problem with access to SipFactory from jsp-pages in JBoss environment

    Hello!
    I have an installation of the OCMS 10.1.3.3. deployed into a JBoss (jboss-4.0.5.GA) environment. Unfortunately I have a problem with accessing the SipFactory from a jps-page. Encouraged by the "messagesender" example I tried to get an instance of SipFactory from my jsp-page simply by calling:
    SipFactory sipFactory = (SipFactory) application.getAttribute(SipServlet.SIP_FACTORY);
    But unfortunately there seems to be no attribute "SipServlet.SIP_FACTORY" and I only get a null pointer. I have also tried running that code in the orignal messagesender example but it didn't work either. So I wonder if this should definetely work in a JBoss environment or if this might be a known problem. Is there anything that I could check/do regarding this problem? I suppose there must be an oracle module which should take care of making the SipFactory availabe after it is deployed. Perhaps something went wrong during the deployment?!
    Best regards,
    Tim

    Hi
    On JBoss, OCMS does not support converge applications.
    I.e the SipFactory can be retrieved from the servlet context when running on OC4J.
    Instead the SipFactory can be found in JNDI as described in the Developer's Guide:
    "External Access to SIP Servlets
    To enable convergent applications between SIP and HTTP, the OCMS Container allows you to get access to the javax.servlet.sip.SipFactory by looking it up through JNDI. The SIP Factory will be registered under the same name as the display name of your SIP servlet as illustrated in Example 2–12. The <display-name> in the sip.xml in this case must be "My sip app".
    Example 2–12 Accessing the Data for a SIP Session through JNDI
    InitialContext ic = new InitialContext();
    SipFactory sipFactory = (SipFactory)ic.lookup("sip/My sip app");"
    Cheers
    Lucas Persson

  • I have problem with Access Connections on L412 after that utilyty upgrade

    I have problem with Access Connections on L412 after that utilyty upgrade in early August. Windows 7 Ultimate/x64.
    It stops connecting to WPA2 Enterprise (AES-CCMP), Microsoft PEAP, no server cert, with any credentials I try to use. The same account(s) works with native Intel manager on other notebooks and on mobile devices. I lost the wireless connectivity to enterprise WiFi network.
    And, after deinstallation of Access Connections, the inability to connect keeped intact with native Win7 WiFi management.
    I think, something was broken in Access Connections 5.83 Build 83C753WW and some registry settings/ dll modules were altered but not returned to normal after deinstall.

    Access Connections is definitely broken for WPA encryption.  Both versions 5.02 and 5.84 fail for me.  If I use the Windows XP wireless configuration instead of Access Connections, everything works.
    Does anyone know how to report this to Lenovo?  I chased links around the web site but couldn't find a place.

  • Just purchased Wndows Vista and having problems with the port for Palm 125

    I just purchased a Windows Vista computer and having problems with getting my Palm 125 to sync with the desktop.  I get an error message saying:  "Com1 not available"  What do I do?
    Thanks,
    Frustrated
    Post relates to: Palm m125
    This question was solved.
    View Solution.

    Sorry, that didn't work.  I get no drop down menu from the Hot Sync Manager for the Serial Port.  What comes up often is:  "The selected port, COM1, is not available at this time.  Hot Sync Manager will open the port when it becomes available." 
    Could it be the Norton Antivirus Firewall that is preventing the Hot Sync Manager to open the Serial Port?  Just a thought.  Thanks for your help.
    Post relates to: Palm m125

  • Can Play iTunes Library from PC on MacBook Air but cannot import, problem with access rights?

    I can play Itunes library from Windows Vista PC on my MacBook Air using homeshare but cannot import the library . Error message is problem with access rights. Latest OS and Itunes installed. Both computers registered with Apple on same Apple ID. Wifi Router turned on and off. Still does not allow importing. Any suggestions please?

    Might be an alternative for you here > iTunes: How to move your music to a new computer

  • Just wondering if anyone has a problem with accessing iTunes store. have iTunes installed but can't bring up the store home page?

    Just wondering if anyone has a problem with accessing iTunes store. have iTunes installed but can't bring up the store home page?

    i have the same problem! Safari won't work either. Can anyone help please? I have completely restored my computer trying to fix this and it still won't work! I have a 2 month old alienware laptop running windows 7

  • I have bought Adobe Photoshop Elements 10 last August 2013 and having problems with installing it on Windows 8.1?

    I have bought Adobe Photoshop Elements 10 last August 2013 and having problems with installing it on Windows 8.1.  Why am I having this problem?

    You can check you Adobe account online to see if the serial number is registered under your account.  If not then your only option will likely be to contact Adobe Support directly thru chat to see if they can provide you with a/the serial number. For them to do so will require you being able to prove ownership.
    Serial number and activation chat support (non-CC)
    http://helpx.adobe.com/x-productkb/global/service1.html ( http://adobe.ly/1aYjbSC )

  • I have Iphoon 4 and ihave problem with speaker what i have to do?

    I have Iphoon 4 and ihave problem with speaker what i have to do?My problem is no body can heir me.
    I have got my IPhoon from London U.K. Now i'm in Saudia Arabia

    If it's happening on all the apps that you've downloaded from the App Store, but not the Apple built-in ones, then try downloading any free app from the store (as that appears to reset something) and then re-try them - the free app can then be deleted.
    If it's happening on all apps then try closing them all completely and then see if they work when you re-open them : from the home screen (i.e.not with any app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of each app to close them, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then you could try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • I have ipad 2 and facing problem with programs swtching off

    I have ipad 2 and facing problem with programs it's swtching off while working and turn to home page. Am using ios 5

    If it's happening on all the apps that you've downloaded from the App Store, but not the Apple built-in ones, then try downloading any free app from the store (as that appears to reset something) and then re-try them - the free app can then be deleted.
    If it's happening on all apps then try closing them all completely and then see if they work when you re-open them : from the home screen (i.e.not with any app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of each app to close them, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then you could try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

Maybe you are looking for

  • Can't get ipod touch to sync manually!

    I have a new 16 gig ipod touch, which I'd like to sync with content on both my home and work computers. I have an iMac G5 at home (running 10.5) and a Macbook at work (running 10.4.10). I also have the latest version of itunes on both machines. I've

  • Message Split in Conversion Agent possible?

    Dear All, Now I am facing a problem of message split in conversion agent. I have a big file which contains lots of records, and the client wants to use conversion agent to split it and send to SAP XI. Is it possible? Is there anyone who has the exper

  • Each batch of IDocs must create one file.

    Hi Experts, I am new to the PI. I am using PI 7.1. I am doing one scenario which is IDOC to file using FCC. I have devloped this interface. In Target side each idoc creats a unique file. But my output file should be,   Each batch of IDocs that PI pro

  • About LTE in Russia

    Good day to you. Lately I've been very disappointed policies in your company. After purchasing the phone from one of your official retailers, I was expecting to use it to the fullest. But I was forced to face the fact that it is not possible.I can no

  • HP Photosmart D7260 need the introductory ink cartridges?

    I was given this printer. It was new and never hooked up before but the introductory ink wasn't given to me with the printer. I had no problem downloading the drivers and setting it up until it got to checking the ink. It gave me an error messages (