I just want to note down and share a useful link https://github.com/maaaaz/sqldeveloperpassworddecryptor with a python script that not only contains a comprehensive user guide but also works. Before stumbling upon it, I also tried some SQL developer plugins that turned out not to work.
Nothing striking. My occasional notes on too rare to remember recurrent IT-related tasks. I would be glad if they were of use to anyone else.
Pages
Tuesday, April 24, 2018
Monday, April 23, 2018
Change schema in Oracle
Even though I do it regularly, I always forget the commands.
To display the current user and the current schema:
SELECT sys_context('USERENV','SESSION_USER') as "USER NAME", sys_context('USERENV', 'CURRENT_SCHEMA') as "CURRENT SCHEMA" FROM dual;
To change the current schema, instead of prefixing the table names:
ALTER SESSION SET CURRENT_SCHEMA = hdm;
Add MySQL or Oracle driver to create a datasource in Wildfly 10
In any other server one simply puts any jar into the library folder to make included in the classpath. In contrast, in Wildfly there is no such a folder - it is based on a modular classloading architecture. One needs to create an individual folder for any additional jar, which is called a module. The official documentation recommends including the required jar in the web archive instead of creating modules. However, this is impossible if one needs to create as datasource, which depends on a driver in the server classpath (A datasource can alternatively be deployed, which I find inconvenient).
Create a new folder path$JBOSS_HOME/modules/system/layers/base/com/mysql/main
Inside the created folder, create a file module.xml with contents:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.3" name="com.mysql"> <resources> <resource-root path="mysql-connector-java-5.1.42-bin.jar"/> </resources> <dependencies> <module name="marian.mysqllogger"/> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
Note, module marian.mysqllogger is obviously optional, it logs the executed SQL commands. It is described in my previous posts.
Create a new folder path$JBOSS_HOME/modules/system/layers/base/com/oracle/main
Inside the created folder, create a file module.xml with contents:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.3" name="com.oracle"> <resources> <resource-root path="ojdbc6.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
Copy a MySQL driver jar indicated in the xml file (e.g. mysql-connector-java-5.1.42-bin.jar) into folder $JBOSS_HOME/modules/system/layers/base/com/mysql/main. The oracle driver indicated in the xml file (e.g. ojdbc6.jar) should also be placed into the folder $JBOSS_HOME/modules/system/layers/base/com/oracle/main with the xml file.
Finally, the datasources can be created in the Administration Console after the Wildfly is restarted.
Alternatively, you can directly edit $JBOSS_HOME/standalone/configuration/standalone.xml. Extend the part dedicated to datasources:
<subsystem xmlns="urn:jboss:domain:datasources:4.0"> <datasources> <datasource jta="true" jndi-name="java:/OracleDS" pool-name="OracleDS" enabled="true" use-ccm="true"> <connection-url>jdbc:oracle:thin:@localhost:1521:orcl2</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <driver>oracle</driver> <security> <user-name>username</user-name> <password>password</password> </security> <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/> <background-validation>true</background-validation> <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/> <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/> </validation> </datasource> <datasource jta="true" jndi-name="java:/MySqlDS" pool-name="MySqlDS" enabled="true" use-ccm="true"> <connection-url>jdbc:mysql://localhost:3306/wildfly?useSSL=false&profileSQL=true&logger=com.mysql.jdbc.log.MySlf4JLogger</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <driver>mysql</driver> <security> <user-name>username</user-name> <password>password</password> </security> <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/> <background-validation>true</background-validation> <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/> </validation> </datasource> <drivers> <driver name="oracle" module="com.oracle"> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> </driver> <driver name="mysql" module="com.mysql"> <driver-class>com.mysql.jdbc.Driver</driver-class> </driver> </drivers> </datasources> </subsystem>
com.mysql.jdbc.log.MySlf4JLogger is a handy logger of executed SQL statements. It is loaded from marian.mysqllogger module.
Restart the Wildfly.