var main = new JDBCConnection();
var con;
try {
con = main.getConnection( url, user, password );
System.log( "Connection to database successful" );
var cstmt = con.prepareCall("{call nameOfStoredProcedure(?,?)}");
cstmt.setString(1,firstParameter);
cstmt.setString(2, anotherParameter);
var rs = cstmt.executeQuery();
//removed line, see comment
//removed line, see above, and then the comment :)
while ( rs.next() ) {
//... Process results of the Stored Procedure, if necessary.
}
rs.close();
cstmt.close();
} catch( ex ) {
throw "Exception during database action " + ex + ")";
} finally {
if (con) {
con.close();
}
– March 1, 2011Posted in: Database, Integrate vCO
With the Database Plugin (which provides JDBC-Classes for your scripting elements) you can execute Stored Procedures, using following Syntax:
Steve Jin: VMware VI and vSphere SDK
David Flanagan: JavaScript – The Definitive Guide
Marijn Haverbeke: Eloquent JavaScript
Cody Bunch: Automating vSphere: With VMware vCenter Orchestrator