Sqlbuilder (OPENHMS) 2.0.10 Publish SQL Build Library

Source: Internet
Author: User
Keywords SQL queries Openhms sqlbuilder build libraries
Tags change code compile embedded http it is java java programs

Sqlbuilder is a SQL build library that reduces the burden of generating SQL queries in Java programs. It uses a programming language (Java) to generate code (that is, SQL) for another language. It is characterized by encapsulating SQL syntax in lightweight, Easy-to-use Java objects, following a builder paradigm similar to StringBuilder. It can change many common SQL syntax and run-time errors to Java compile-time errors.

A simple SQL select query code embedded in a Java program, as follows:

Assuming a produced of predefined string constants
String selectquery = "Select" + T1_col1 + "," + T1_col2 + "," +
&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; T2_col1 + "from" + TABLE1 + "" + T1 + "INNER JOIN" +
TABLE2 + "" + T2 + "on (" + t1_idcol + "=" + T2_idcol +
") Order BY" + t1_col1;

The code to try to improve is as follows:

String selectquery = Messageformat.format (
' Select {0},{1},{2} from {3} {4} ' INNER JOIN {5} {6} ' ({7} = {8}) +
' ORDER by {9} ',
T1_col1, T2_col2, T2_col1, TABLE1, T1, TABLE2, T2,
T1_idcol, T2_idcol, t1_col1);

The Sqlbuilder class corresponds to the following code:

Assuming these objects have already been created
Table table1, table2;
Column t1col1, T1col2, t2col1;
Join JOINOFT1ANDT2;

String SelectQuery =
(New SelectQuery ())
. Addcolumns (T1col1, T1col2, T2col1)
. Addjoin (SelectQuery.JoinType.INNER_JOIN, JOINOFT1ANDT2)
. Addorderings (T1col1)
. Validate (). toString ();

The Sqlbuilder (OPENHMS) version 2.0.10 is primarily about adding flexibility to support SQL constructs. The associated SQL construct has no alias handling table, and dbtable can now build a clear alias. Add SelectQuery addcustomjoin to allow full 17813.html "> customizable join clauses. Combocondition, Unarycondition, binarycondition, and comboexpression can now customize operators. Now all the options for the condition and expression to disable the wrapping bracket.

Software Information: http://openhms.sourceforge.net/sqlbuilder/

Download Address: Http://nchc.dl.sourceforge.net/project/openhms/sqlbuilder/sqlbuilder%202.0.10/sqlbuilder-2.0.10.jar

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.