Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
SuperArmy
New Member.
312 views

Groovy script with JDBC

Hi Experts,

We want to integrate OMi with iTOP which is a open-source service management tool.

So I tried to add  a script in a TBEA rule, this script is very simple just for testing.

 

import groovy.sql.Sql

class GroovyScriptiTOPExchange
{
    void init()
    {
       def sql = Sql.newInstance("jdbc:jtds:sqlserver://*.*.*.*/iTOPExchange", "iTOP", "***", "net.sourceforge.jtds.jdbc.Driver")
    }
	
  void main()
  {
      
    def id="123"
    def title="event title"
    def content="event content"
    sql.execute("insert into newevent(id, title, content) values (${id}, ${title}, ${content})")
  }

	void destroy()
		{
			sql.close()
		}  
}

 

But it couldn't be loaded successfully, here are some informations in  opr-scripting-host.log

2016-03-15 13:27:22,085 [RMI TCP Connection(79)-10.254.13.22] WARN ScriptExecutionService.execute(172) - : No script with id 5ffee33d-4338-8e3b-808b-789d40d13f46 available for processing events. Verify that it has been loaded successfully.
2016-03-15 13:27:22,085 [RMI TCP Connection(79)-10.254.13.22] WARN RemoteInvocationTraceInterceptor.invoke(88) - Processing of RmiServiceExporter remote call resulted in fatal exception: com.hp.opr.common.epi.EpiProcessingInterface.process: Script with id 5ffee33d-4338-8e3b-808b-789d40d13f46not available. Verify that it has been loaded successfully. -- com.hp.opr.common.epi.ScriptNotAvailableException: No script with id 5ffee33d-4338-8e3b-808b-789d40d13f46 available for processing events. Verify that it has been loaded successfully. -- No script with id 5ffee33d-4338-8e3b-808b-789d40d13f46 available for processing events. Verify that it has been loaded successfully.

 

Could someone advise me where can I get more informations about this error?

 

Rgds.

-Jun

0 Likes
5 Replies
Absent Member.. Edgar_A_OMI Absent Member..
Absent Member..

Re: Groovy script with JDBC

Hello.

Which software version are you using?

Is this an out of the box script or you created it?

Regards,

Edgar Araya
SW Support Technical Consultant
San Jose, Costa Rica
hpe.com
Hewlett Packard Enterprise

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
0 Likes
SuperArmy
New Member.

Re: Groovy script with JDBC

Hi Edgar,

 

It's the script I wrote. I didn't write Groovy/JAVA code before, but I am trying to write a script whcih can insert the events into an external database table.

I modified this test script and it works now.

import java.util.List;
import com.hp.opr.api.scripting.Event;
import groovy.sql.Sql

class GroovyScriptiTOPExchange
{
    def init()
    {
     // def sql = Sql.newInstance("jdbc:jtds:sqlserver://10.254.13.20/iTOPExchange", "iTOP", "iTOP2016", "net.sourceforge.jtds.jdbc.Driver")
    }
	
  def process(List<Event> events)
  {
     try
    {
    def sql = Sql.newInstance("jdbc:jtds:sqlserver://10.254.13.20:1433/iTOPExchange", "iTOP", "iTOP2016", "net.sourceforge.jtds.jdbc.Driver")
    def id="123"
    def title="event title"
    def content="event content"
    sql.execute("insert into newevent(id, title, content) values (${id}, ${title}, ${content})")
   }

    catch(InterruptedException e)
    {
      return
    }
  }

	def destroy()
		{
			sql.close()
		}  
}

Regards,

Jun

Acclaimed Contributor.. Harald Acclaimed Contributor..
Acclaimed Contributor..

Re: Groovy script with JDBC

Hello,

your script requires an additional jar file containing the driver you are loading with new Instance -> net.sourceforge.jtds.jdbc.Driver

You need to upload this with your script.

Kind regards,
Harald

 

eertul2 Regular Contributor.
Regular Contributor.

Re: Groovy script with JDBC

The point shouldn't be like "I did, use this.".

People are reading topics to find a similiar cases about their own problems. By this way,  no one can see your opinion about problem or solution to their's to compare.

Can you explain what was the problem and what did you do and why.

Thanks for the understanding.

Erhan ERTUL, TEB
0 Likes
ThomasLanz Honored Contributor.
Honored Contributor.

Re: Groovy script with JDBC

hi there, seems there is a general issue with the script. check scripts.log in opr-epi-scripting directory.

As harald pointed it might be a missing driver jar.

Just as tip of performanace:

I do very often event enrichments from external DBs  or local RTSM. I always suggest to use a cache in memory. Means you should load the data using sql statement into local HashMap and process this hashmap in every event instead of doing sql query for each event.
Of course from time to time you need to refresh your cache. hope you get the idea..

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.