Java/SQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maxi

    Java/SQL

    I have this SQL statement and I need to change the WHERE clause in the SQL
    statement to its java equivatlent. Something like this:

    @command1, @username2 ,@receiver is input parameter

    WHERE
    (
    [Test]=2
    AND
    (command LIKE @command1 AND Username2 LIKE @Username2)
    AND
    (lac is null or lac=@receiver)
    )

    Java equivatlent:
    if( (Test == 2) & (command LIKE @command1 & username2 LIKE @username2) &
    (lac is null | lac== receiver)
    ...........

    But I have trouble with translating LIKE, is null and lac=@reciver


  • Millian Brave

    #2
    Re: Java/SQL

    Maxi,

    When comparing for equality in Java you use "==" not "=", thus the part
    "lac=@recei ver" would in Java be represented as "lac==@receiver ".

    As for the LIKE-thingy you have nothing like this in Java (the standard API
    that is; somebody somewhere surely to have implemented it somehow ;-)). But
    you could try using regular expressions. Check out the regular expression
    notes in the String-class description as a starting point.


    --
    Millian Brave


    "Maxi" <dilorjaan50@ho tmail.com> skrev i melding
    news:3f8bdc09$0 $9736$edfadb0f@ dread14.news.te le.dk...[color=blue]
    > I have this SQL statement and I need to change the WHERE clause in the SQL
    > statement to its java equivatlent. Something like this:
    >
    > @command1, @username2 ,@receiver is input parameter
    >
    > WHERE
    > (
    > [Test]=2
    > AND
    > (command LIKE @command1 AND Username2 LIKE @Username2)
    > AND
    > (lac is null or lac=@receiver)
    > )
    >
    > Java equivatlent:
    > if( (Test == 2) & (command LIKE @command1 & username2 LIKE @username2) &
    > (lac is null | lac== receiver)
    > ...........
    >
    > But I have trouble with translating LIKE, is null and lac=@reciver
    >
    >[/color]


    Comment

    Working...