001/* 002 * JKNIV, whinstone one contract to access your database. 003 * 004 * Copyright (C) 2017, the original author or authors. 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software Foundation, Inc., 018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 019 */ 020package net.sf.jkniv.whinstone.jdbc.dialect; 021 022import net.sf.jkniv.sqlegance.dialect.AnsiDialect; 023import net.sf.jkniv.sqlegance.dialect.SqlFeatureFactory; 024import net.sf.jkniv.sqlegance.dialect.SqlFeatureSupport; 025 026/** 027 * Dialect to DB2 with compatibility features for MySQL applications. 028 * <p> 029 * Limit clause: 030 * <code>select name from author LIMIT 1 OFFSET 2</code> 031 * </p> 032 * <ul> 033 * <li>Supports limits? true</li> 034 * <li>Supports limit off set? true</li> 035 * <li>Supports rownum? false</li> 036 * </ul> 037 * 038 *<p> 039 * The DB2_COMPATIBILITY_VECTOR registry variable enables one or more DB2® compatibility features. 040 * These features ease the task of migrating applications that were written for relational database 041 * products other than the DB2 product to DB2 Version 9.5 or later. 042 *</p> 043 *<p> 044 * This registry variable is supported on Linux, UNIX, and Windows operating systems. 045 * You can enable individual DB2 compatibility features by specify a hexadecimal value 046 * for the registry variable. Each bit in the variable value enables a different feature. Values are as follows: 047 *</p> 048 *<pre> 049 * NULL (default) 050 * 0000 - FFFF 051 * ORA, to take full advantage of the DB2 compatibility features for Oracle applications 052 * SYB, to take full advantage of the DB2 compatibility features for Sybase applications 053 * MYS, to take full advantage of the DB2 compatibility features for MySQL applications 054 *</pre> 055 * 056 * @see <a href="http://www.ibm.com/support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.apdv.porting.doc/doc/r0052867.html">DB2 compatibility Oracle/Sybase/MySQL</a> 057 * 058 * @author Alisson Gomes 059 * @since 0.6.0 060 */ 061public class DB2EnableMYSDialect extends AnsiDialect 062{ 063 public DB2EnableMYSDialect() 064 { 065 super(); 066 addFeature(SqlFeatureFactory.newInstance(SqlFeatureSupport.LIMIT, true)); 067 addFeature(SqlFeatureFactory.newInstance(SqlFeatureSupport.LIMIT_OFF_SET, true)); 068 } 069 070 /** 071 * LIMIT and OFFSET clause for DB2 with DB2_COMPATIBILITY_VECTOR=MYS enabled, 072 * where LIMIT and OFFSET are parameter from String.format 073 * 074 * @return Return query pattern: 075 * 076 * select name from author LIMIT 1 OFFSET 2 077 * 078 */ 079 @Override 080 public String getSqlPatternPaging() 081 { 082 return "%1$s LIMIT %2$s OFFSET %3$s"; 083 } 084}