It is a solution say when we
do integration test using Hyper SQLDB, if the SQL statement have functions which in-memory DB not
support, we can use Java Language Routines to mimic the logic the specific-DB-function
performs.
An examples is if the specific DB is SQL Server, and the SQL
statement has LEN() function which will return the length of the varchar, in
SQL Server, however, HSQLDB not support LEN() function (only support length()),
and also we will not write a specific SQL for HSQLDB for testing purpose, in
this case, we can use Java Language Routines which is a static method of
a Java class, specified with a fully qualified method name in the routine
definition.
Step 1:
define a Java class and a
static method to mimic the function you need
For this case, I need a method by providing a string and return the length of
string, so the method may look like below:
public class JavaRoutinesForHSql {
public static int stringLength(String chars){ if (chars!=null) return chars.trim().length(); return 0; } }
Step 2: define the routine in sql script
Before the SQL statement is called, create the function as below:
Step 3: you can drop the custom routine if needed:
For more information, please refer to: http://hsqldb.org/doc/guide/sqlroutines-chapt.html#src_jrt_routines
Awesome Blog!!! Thanks for sharing this data with us... oracle training in chennai
ReplyDeleteAfter reading your article I was amazed. I know that you explain it very well
ReplyDeleteSelenium Course in Coimbatore | Selenium Training Course in Coimbatore | Best Selenium Training in Coimbatore | Selenium Training Institute in Coimbatore | Online Selenium Course Training in Coimbatore | Selenium Training in Saravanampatti | Selenium Testing Training Course in Coimbatore
Thank you so much for sharing.It will help everyone.Keep Post.
ReplyDeleteTop 10 java training institute in coimbatore |Java Training institute Coimbatore | software Testing Course in Coimbatore | Selenium Training Coimbatore | Automation Testing | Selenium Training institute Coimbatore | Best Selenium Training institute Coimbatore | Online selenium Training institute Coimbatore | software Testing Course in Coimbatore | Best Online software testing training institutes in coimbatore | Best software Testing Training Course in Coimbatore | Online software testing course in coimbatore | Manual and Automation Testing Training in saravanampatti