If the specified querying string has a sub-querying - Java java.lang

Java examples for java.lang:String SQL

Description

If the specified querying string has a sub-querying

Demo Code

//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] argv) {
        String ql = "select from (select from)";
        System.out.println(containsSubquery(ql));
    }/*from w w w . j  av a2s  .  c om*/

    /**
     * If the specified querying string has a sub-querying
     * 
     * @param ql
     * @return
     */
    public static boolean containsSubquery(String ql) {
        String regEx = "from (.])";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(ql.toUpperCase());
        return m.find();
    }
}

Related Tutorials