Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    try null catch, or something else

    if con.rs.getString("prop") comes out null this will go to exception, coz split would not work

    In dilema if this is best way to do it(performance, ...) ? Because I have a bunch of similar things in same procedure.

    Code:
    try
    {
      this.prop= con.rs.getString("prop").split("\\|")[1];
    }
    catch(Exception ex)
    {  
       this.prop= "";
    }

  • #2
    Regular Coder Aradon's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    734
    Thanks
    0
    Thanked 20 Times in 19 Posts
    Can you not just check if the String is Null (Or even if it just equals "")? Or you could check the length, or any other sort of various things I believe.
    "To iterate is human, to recurse divine." -L. Peter Deutsch

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    94
    Thanks
    0
    Thanked 16 Times in 16 Posts
    try
    {
    this.prop= con.rs.getString("prop");
    if(this.prop != null){
    this.prop= this.prop.split("\\|")[1];
    }
    }
    catch(Exception ex)
    {
    this.prop= "";
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •