Topic:

Scripting

Ephesoft Versions:

v4.0+

 

Instructions:

User will need to write custom scripts to insert data in ‘custom_column(s)’ of ‘batch_instance’ table which will be shown on Batch Instance Management Grid.

The data can be fetched from Batch XML or any other data source.

 

Sample Code:

public void updateCustomValues(String... values) {

                    

              Connection connection = null;

              Statement statement = null;

              try {

                     // STEP 1: Register JDBC driver(SQL SERVER IN THIS EXAMPLE)

                     Class.forName("net.sourceforge.jtds.jdbc.Driver");

 

                     // STEP 2: Open a connection

                     System.out.println("Connecting to a selected database...");

                     connection = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433;databaseName=ephesoft;sendStringParametersAsUnicode=false;prepareSQL=3", "root", "");

                     System.out.println("Connected database successfully...");

 

                     // STEP 3: Execute a query

                     System.out.println("Updating records into the table...");

                     statement = connection.createStatement();

 

                     String sql = "UPDATE batch_instance SET custom_column1= '" + values[0] + "' WHERE identifier='BI1'";

                     statement.executeUpdate(sql);

                    

                     System.out.println("Records succssfully updated into the table...");

 

              } catch (SQLException sqlException) {

                     // Handle errors for JDBC

              } catch (Exception exception) {

                     // Handle errors for Class.forName

              } finally {

                     // finally block used to close resources

                     try {

                           if (statement != null)

                                  connection.close();

                     } catch (SQLException se) {

                     }// do nothing

                     try {

                           if (connection != null)

                                  connection.close();

                     } catch (SQLException se) {

                           se.printStackTrace();

                     }// end finally try

              }// end try

       }

 

< Back | Main Documentation Page|

Was this article helpful to you?

wikiadmin

Comments are closed.