SQL Single-quote double-quote concatenation variable in Java

Source: Internet
Author: User

String sqlstring= "SELECT * from Tb_wf_main where trim (wf_name) = '" + wfname.trim () + "' ";


The string in Java can only double quotation marks (JS can be single quotation marks can also be double quotes), above, if the string needs to stitch the variable, the variable is enclosed in single quotation marks, and then add two double quotation marks plus two Plus, the middle is a variable

Just keep it that way: single quotes enclose two plus-sign intermediate variables (0q0 OMG)

JS is also a way to splice variables.

For example:

1  PublicJsonobject querydata (String startdate,string enddate,string stationid,string slenodeid,string bomOprId,String Lackflag,intPageNumber,2             intpageSize)3     {4StringBuffer HQL =NewStringBuffer ("from Operatordetail t where 1=1");5         if(!Stringutils.isblank (startdate))6         {7Hql.append ("and t.operatedate >= '" + startdate + "'");8         }9         if(!Stringutils.isblank (endDate))Ten         { OneHql.append ("and t.operatedate <= '" + endDate + "'"); A         } -         if(!Stringutils.isblank (stationId)) -         { theHql.append ("and T.stationid = '" + stationId + "'"); -         } -         if(!Stringutils.isblank (Slenodeid)) -         { +Hql.append ("and T.slenodeid = '" + Slenodeid + "'"); -         } +         if(!Stringutils.isblank (Bomoprid)) A         { atHql.append ("and T.bomoprid = '" + Oprid + "'"); -         } -         if(!Stringutils.isblank (lackflag)) -         { -Hql.append ("and T.lackflag =" + Lackflag + ""); -         } inHql.append ("ORDER by T.operatedate"); -map<string, object> recordmap = Queryobjectspage (Hql.tostring (), (pageNumber-1) *pageSize, pageSize); to         returnJsonobject.fromobject (recordmap); +}

SQL Single-quote double-quote concatenation variable in Java

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.