Database Reference
In-Depth Information
ELSE
app_sec_pkg.p_log_error( 0, 'Problem copying App Conns, ' || return_user );
END IF;
-- Raise Exceptions
EXCEPTION
WHEN OTHERS THEN
m_err_no := SQLCODE;
m_err_txt := SQLERRM;
app_sec_pkg.p_log_error( m_err_no, m_err_txt,
'p_copy_app_conns' );
END p_copy_app_conns;
Java Stored Procedure to Copy Connection Strings
Once again, we call an Oracle stored function, which is really just a wrapper for a method written in Java
that will accomplish the task. This function, f_copy_conns in Listing 11-28 calls the copyPreviousConns()
method.
Listing 11-28. Java Stored Procedure to Copy Connection Strings, f_copy_conns
FUNCTION f_copy_conns( class_instance RAW, class_version VARCHAR2 )
RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'orajavsec.OracleJavaSecure.copyPreviousConns( oracle.sql.RAW, java.lang.String )
return java.lang.String';
Database Java Method to Copy Connection Strings
copyPreviousConns() is perhaps the most complex method we will study; however, it is only complex in
managing multiple versions of our application at once, not in the process. We are going to be performing
steps that we have accomplished in other methods that we have examined. Here, though, we will go
back and forth between the new and old versions of the inner class.
Our first step is to get the current inner class name and version number (shown in Listing 11-29)
directly from the inner class, classInstance RAW parameter. We do this by getting the bytes of the RAW
and pushing them through a ByteArrayInputStream , then through an ObjectInputStream , from which we
read an Object as the providedClass member. From that Object , we can read the name into the
className member. We can also get the getRevLvl() method and read the revision level into the
classVersion member.
Listing 11-29. Get New Class Version and Name
byte[] appClassBytes = classInstance.getBytes() ;
ByteArrayInputStream bAIS = new ByteArrayInputStream( appClassBytes );
ObjectInputStream oins =
new ObjectInputStream( bAIS );
Object classObject = oins.readObject() ;
oins.close();
Class providedClass = classObject.getClass();
 
Search WWH ::




Custom Search