Use Dbms_Application_Info.Set_Module(module_, action_) for the application.
1.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java Tue Apr 23 15:38:47 2013 +0200
1.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java Wed Apr 24 08:49:17 2013 +0530
1.3 @@ -437,6 +437,7 @@
1.4 JMenuItem item = (JMenuItem) e.getSource();
1.5 DatabaseConnection newConnection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
1.6 if (setConnection(newConnection)) {
1.7 + connectionProvider.setModuleInOracle(connection);
1.8 saveAndExecute();
1.9 }
1.10 }
2.1 --- a/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/DatabaseConnectionManager.java Tue Apr 23 15:38:47 2013 +0200
2.2 +++ b/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/DatabaseConnectionManager.java Wed Apr 24 08:49:17 2013 +0530
2.3 @@ -47,6 +47,7 @@
2.4 import java.beans.PropertyChangeSupport;
2.5 import java.io.File;
2.6 import java.lang.reflect.InvocationTargetException;
2.7 +import java.sql.CallableStatement;
2.8 import java.sql.Connection;
2.9 import java.sql.Driver;
2.10 import java.sql.PreparedStatement;
2.11 @@ -307,9 +308,11 @@
2.12 }
2.13 }
2.14 logger.log(Level.FINEST, "Creating new connection. Total number of connections created={0}", ++connectionCount);
2.15 - return DatabaseConnection.create(templateConnection.getJDBCDriver(), templateConnection.getDatabaseURL(), templateConnection.getUser(), templateConnection.getSchema(), templateConnection.getPassword(), true, templateConnection.getDisplayName());
2.16 + connection = DatabaseConnection.create(templateConnection.getJDBCDriver(), templateConnection.getDatabaseURL(), templateConnection.getUser(), templateConnection.getSchema(), templateConnection.getPassword(), true, templateConnection.getDisplayName());
2.17 + setModuleInOracle(connection);
2.18 + return connection;
2.19 }
2.20 - }
2.21 + }
2.22
2.23 public DatabaseConnection getTemplateConnection() {
2.24 if (templateConnection != null) {
2.25 @@ -455,11 +458,29 @@
2.26 this.debugConnection = null;
2.27 changeSupport.firePropertyChange(PROP_DATABASE_CONNECTIONS, oldConnections, newConnections);
2.28 }
2.29 +
2.30 + public void setModuleInOracle(final DatabaseConnection connection){
2.31 + try {
2.32 + ResultSet rs = null;
2.33 + CallableStatement stmt=null;
2.34 + if (connection == null || connection.getJDBCConnection() == null) {
2.35 + return;
2.36 + }
2.37 + String sqlProc = "{call Dbms_Application_Info.Set_Module(?,?)}";
2.38 + stmt = connection.getJDBCConnection().prepareCall(sqlProc);
2.39 + stmt.setString(1, "NetBeans");
2.40 + stmt.setString(2, "Main Program");
2.41 + stmt.executeUpdate();
2.42 + } catch (SQLException ex) {
2.43 + // Exceptions.printStackTrace(ex);
2.44 + logger.log(Level.WARNING, "Error when adding Module in v$Session");
2.45 + }
2.46 + }
2.47
2.48 public synchronized void connect(final DatabaseConnection connection) {
2.49 if (connection == null) {
2.50 return;
2.51 - }
2.52 + }
2.53 boolean onlineBeforeConnect = isOnline();
2.54 boolean failed = false;
2.55 try {
2.56 @@ -478,6 +499,7 @@
2.57 if (SwingUtilities.isEventDispatchThread()) {
2.58 try {
2.59 ConnectionManager.getDefault().showConnectionDialog(connection);
2.60 + setModuleInOracle(connection);
2.61 } catch (NullPointerException e) {
2.62 failed = true;
2.63 } catch (IllegalStateException e) {
2.64 @@ -490,6 +512,7 @@
2.65 @Override
2.66 public void run() {
2.67 ConnectionManager.getDefault().showConnectionDialog(connection);
2.68 + setModuleInOracle(connection);
2.69 }
2.70 });
2.71 } catch (InterruptedException e) {
2.72 @@ -507,6 +530,7 @@
2.73 public void run() {
2.74 try {
2.75 ConnectionManager.getDefault().connect(connection);
2.76 + setModuleInOracle(connection);
2.77 } catch (DatabaseException ex) {
2.78 }
2.79 }
2.80 @@ -519,6 +543,7 @@
2.81 } else {
2.82 try {
2.83 ConnectionManager.getDefault().connect(connection);
2.84 + setModuleInOracle(connection);
2.85 } catch (DatabaseException ex) {
2.86 failed = true;
2.87 }