Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
dev:jdbc:router [2009/11/30 16:18]
tdo created
dev:jdbc:router [2016/06/28 22:38] (current)
Line 121: Line 121:
  
 The business rules can be declared using one of two approaches. ​ The simplest approach is to declare a series of conditions using regular expressions,​ and once a condition tests positive, then the corresponding server is used.  The more powerful approach is to use Java code to create a rule that evaluates the statement, choose the server and customizes the connection settings. ​ This is done by extended a base class that is provided by Omnidex. ​ This extended class has access to the complete SQL statement and all server connection information. ​ The extended class can then evaluate the statement, alter the statement, choose a server and modify the connection information as needed. The business rules can be declared using one of two approaches. ​ The simplest approach is to declare a series of conditions using regular expressions,​ and once a condition tests positive, then the corresponding server is used.  The more powerful approach is to use Java code to create a rule that evaluates the statement, choose the server and customizes the connection settings. ​ This is done by extended a base class that is provided by Omnidex. ​ This extended class has access to the complete SQL statement and all server connection information. ​ The extended class can then evaluate the statement, alter the statement, choose a server and modify the connection information as needed.
- 
- 
 ===== Declaring business rules using regular expressions ===== ===== Declaring business rules using regular expressions =====
  
Line 193: Line 191:
 </​code>​ </​code>​
  
-Declaring business rules using Java+===== Declaring business rules using Java =====
  
 Business rules that use Java are declared in the configuration file using the following settings: Business rules that use Java are declared in the configuration file using the following settings:
Line 211: Line 209:
  
 The following examples show how rules that use Java are declared in the configuration file: The following examples show how rules that use Java are declared in the configuration file:
 +<code xml>
 <​rules>​ <​rules>​
   <​rule>​   <​rule>​
Line 235: Line 233:
   <​initialRule>​org.mycompany.omnidex.routeQueries</​initialRule>​   <​initialRule>​org.mycompany.omnidex.routeQueries</​initialRule>​
 </​rules>​ </​rules>​
-  +</​code>​  
- +===== Writing Extended Classes in Java =====
-Writing Extended Classes in Java+
  
 The Omnidex JDBC Intelligent Router provides a set of base classes that can be extended for each Java-based rule declared in the configuration file.  From within this class, the author can obtain the SQL Statement, evaluate the SQL statement using whatever approach they wish, and even alter the SQL statement. ​ The class returns an OdxJDBCRouterServer object indicating which server should be used.  This server object may be looked up in the configuration file, and the connection string and connection pooling information may then be modified if needed. ​ It is also possible to create an OdxJDBCRouterServer object dynamically without first looking it up in the configuration file. The Omnidex JDBC Intelligent Router provides a set of base classes that can be extended for each Java-based rule declared in the configuration file.  From within this class, the author can obtain the SQL Statement, evaluate the SQL statement using whatever approach they wish, and even alter the SQL statement. ​ The class returns an OdxJDBCRouterServer object indicating which server should be used.  This server object may be looked up in the configuration file, and the connection string and connection pooling information may then be modified if needed. ​ It is also possible to create an OdxJDBCRouterServer object dynamically without first looking it up in the configuration file.
Line 249: Line 246:
 The example shows extending the OdxJDBCRouterRule class for the routeQueries rule: The example shows extending the OdxJDBCRouterRule class for the routeQueries rule:
  
 +<code java>
 package org.mycompany.omnidex;​ package org.mycompany.omnidex;​
  
Line 258: Line 256:
   /**   /**
    * Process the rule, which returns a single    * Process the rule, which returns a single
-   ​* ​<​code>​OdxJDBCRouterServer</​code> ​object.+   * OdxJDBCRouterServer object.
    *    *
-   * @return a <​code>​OdxJDBCRouterServer</​code> ​object that contains the server +   * @return a OdxJDBCRouterServer object that contains the server 
-   ​* ​        ​information or <​code>​null</​code> ​object if the rule is not passed.+   ​* ​        ​information or null object if the rule is not passed.
    * @exception Exception if an error occurs.    * @exception Exception if an error occurs.
    */    */
Line 295: Line 293:
   }   }
 } }
-  +</​code>​ 
-Declaring the Rule to be Evaluated+ 
 +===== Declaring the Rule to be Evaluated ​===== 
  
 When the router is called, the rule to be executed is declared in the initialRule element of the rules section. ​ Alternatively,​ the rule to be executed can be sent in the connection string using the following syntax: When the router is called, the rule to be executed is declared in the initialRule element of the rules section. ​ Alternatively,​ the rule to be executed can be sent in the connection string using the following syntax:
Line 302: Line 302:
  jdbc:​omnidex:​router:​config_filename[/​rule]  jdbc:​omnidex:​router:​config_filename[/​rule]
    
-Calling the Omnidex JDBC Intelligent Router+===== Calling the Omnidex JDBC Intelligent Router ​===== 
  
 The following Java snippet shows an example of calling the Omnidex JDBC Intelligent Router. ​ Some of the methods that display to the screen or close the database are not shown, but they are available on the Omnidex software distribution if needed. The following Java snippet shows an example of calling the Omnidex JDBC Intelligent Router. ​ Some of the methods that display to the screen or close the database are not shown, but they are available on the Omnidex software distribution if needed.
 
Back to top
dev/jdbc/router.1259597930.txt.gz · Last modified: 2016/06/28 22:38 (external edit)