Notes by Dr. Xi
Displaying notes 21 - 30
Created by Dr. Xi on June 03, 2010 18:29:59
Last update: June 03, 2010 18:31:49
Generate a private key and store it in the keystore. The keystore file theKeyStore.jks will be created if it does not exist. The default keystore file is $HOME/.keystore if the -keystore option is not given. keytool -genkey -alias myjavakey -keyalg RSA -keystore theKeyStore.jks Generate a private key and self-sign for 10 years. keytool -genkey -alias myjavakey -keyalg RSA -validity 3650 List keys in the keystore. # short list keytool -list -keystore theKeyStore.jks # long list keytool -list -v -keystore theKeyStore.jks # show one key keytool -list -v -keystore theKeyStore.jks -alias myjavakey Create a certificate signing request (CSR). keytool -certreq -alias myjavakey -keystore theKeyStore.jks -file myjavakey.csr It seems that the Java keytool utility can't sign third party certificate signing requests (CSRs). We can use openssl to ...
Created by Dr. Xi on June 01, 2010 16:44:12
Last update: June 01, 2010 16:45:52
I installed JDK 1.6 under C:\jdk1.6.0_20 and unpacked Eclipse GALILEO in C:\local\eclipse . When I launched Eclipse with eclipse.exe , it simply displayed a splash page and shutdown. Running eclipsec.exe displayed some vague errors: C:\local\eclipse>eclipsec Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries Turning on debug: C:\local\eclipse>eclipsec -debug Start VM: -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -XX:MaxPermSize=256m -Djava.class.path=C:\local\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201. R35x_v20090715.jar -os win32 -ws win32 -arch x86 -showsplash C:\local\eclipse\\plugins\org.eclipse.platform_3.3.202.v201002111343\splash.bmp -launcher C:\local\eclipse\eclipsec.exe -name Eclipsec --launcher.library C:\local\eclipse\plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519\eclipse_1206.dll -startup C:\local\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v200 90715.jar -product org.eclipse.epp.package.jee.product -debug -vm C:\jdk1.6.0_20\bin\client\jvm.dll -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -XX:MaxPermSize=256m -Djava.class.path=C:\local\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201. R35x_v20090715.jar Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries The Solution: add -vm option to eclipse.ini : -startup plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519 -product org.eclipse.epp.package.jee.product --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform ...
Created by Dr. Xi on May 23, 2010 01:16:57
open(IMG, "Sample.jpg") or die "Can't open file: $!"; binmode IMG; binmode STDOUT; while (read(IMG, $buff, 8 * 2 ** 10)) { print $buff; } close IMG;
Created by Dr. Xi on May 15, 2010 19:53:27
Last update: May 15, 2010 19:54:37
Use the locale module. >>> a = 1234.5678 >>> import locale >>> locale.setlocale(locale.LC_ALL, '') # set default locale 'English_United States.1252' >>> locale.currency(a) '$1234.57' >>> locale.currency(a, grouping=True) '$1,234.57' >>>
Created by Dr. Xi on April 07, 2010 15:46:14
SQL> desc user_role_privs; Name Null? Type ----------------------------------------- -------- ---------------------------- USERNAME VARCHAR2(30) GRANTED_ROLE VARCHAR2(30) ADMIN_OPTION VARCHAR2(3) DEFAULT_ROLE VARCHAR2(3) OS_GRANTED VARCHAR2(3) SQL> select * from user_role_privs; USERNAME GRANTED_ROLE ADM DEF OS_ ------------------------------ ------------------------------ --- --- --- PET_STORE DBA NO NO NO PET_STORE DBA_READ_ONLY NO YES NO PET_STORE PET_WRITE NO YES NO PET_STORE PET_READ_ONLY NO YES NO SQL> desc dba_role_privs; Name Null? Type ----------------------------------------- -------- ---------------------------- GRANTEE VARCHAR2(30) GRANTED_ROLE NOT NULL VARCHAR2(30) ADMIN_OPTION VARCHAR2(3) DEFAULT_ROLE VARCHAR2(3) SQL> select * from dba_role_privs where grantee = 'PET_STORE'; GRANTEE GRANTED_ROLE ADM DEF ------------------------------ ------------------------------ --- --- PET_STORE DBA NO NO PET_STORE PET_WRITE NO YES PET_STORE DBA_READ_ONLY NO YES PET_STORE PET_READ_ONLY NO YES Further reference: Oracle Database Security Guide (11g Release 2)
Created by Dr. Xi on April 06, 2010 22:55:13
Last update: April 06, 2010 22:56:38
These are the steps to diagnose the "javax.jms.Destination found at the specified destination-location" error an MDB in the Oracle application server (oc4j) environment. The data source is correctly configured and connection can be successfully established. Test this from the Oracle AS em console. The destination queue exists and is started. If you are using PL/SQL Developer, you can check this by right clicking on the queue name and make sure that "Enqueue Enabled" and "Dequeue Enabled" are checked. Deployment descriptors are correctly set up. The database user used for the JDBC connection pool has the proper privileges to enqueue and dequeue. Usually this means that the database user is assigned the AQ_USER_ROLE . The ultimate test is to run some PL/SQL code in the oc4j ...
Created by Dr. Xi on March 31, 2010 19:32:42
Last update: March 31, 2010 19:41:14
The dev database keeps locking up because of failed login attempts. For a dev database, we really don't need such security measure. This is how to remove the limit. Log in as sysdba sqlplus sys@xe as sysdba Find out the profile for the user. SQL> select profile from dba_users where username = 'HIBERNATE'; PROFILE ------------------------------ DEFAULT Look at the current limits SQL> select resource_name, limit from dba_profiles where profile = 'DEFAULT'; RESOURCE_NAME LIMIT -------------------------------- ---------------------------------------- COMPOSITE_LIMIT UNLIMITED SESSIONS_PER_USER UNLIMITED CPU_PER_SESSION UNLIMITED CPU_PER_CALL UNLIMITED LOGICAL_READS_PER_SESSION UNLIMITED LOGICAL_READS_PER_CALL UNLIMITED IDLE_TIME UNLIMITED CONNECT_TIME UNLIMITED PRIVATE_SGA UNLIMITED FAILED_LOGIN_ATTEMPTS 10 PASSWORD_LIFE_TIME UNLIMITED RESOURCE_NAME LIMIT -------------------------------- ---------------------------------------- PASSWORD_REUSE_TIME UNLIMITED PASSWORD_REUSE_MAX UNLIMITED PASSWORD_VERIFY_FUNCTION NULL PASSWORD_LOCK_TIME UNLIMITED PASSWORD_GRACE_TIME UNLIMITED 16 rows selected. Increase the value for failed login attempts SQL> alter profile default ...
Created by Dr. Xi on March 31, 2010 19:18:33
Query the dba_users view to find locked accounts. SQL> select username, account_status, lock_date from dba_users order by username; USERNAME ACCOUNT_STATUS LOCK_DATE ------------------------------ -------------------------------- --------- ANONYMOUS OPEN CTXSYS EXPIRED & LOCKED 20-NOV-06 DBSNMP EXPIRED & LOCKED 07-FEB-06 DIP EXPIRED & LOCKED 07-FEB-06 FLOWS_020100 EXPIRED & LOCKED 07-FEB-06 FLOWS_FILES EXPIRED & LOCKED 07-FEB-06 HIBERNATE OPEN HR EXPIRED & LOCKED 20-NOV-06 JEMUSER OPEN JPA OPEN MDSYS EXPIRED & LOCKED 07-FEB-06 USERNAME ACCOUNT_STATUS LOCK_DATE ------------------------------ -------------------------------- --------- OUTLN EXPIRED & LOCKED 20-NOV-06 SRDEMO OPEN SYS OPEN SYSTEM OPEN TSMSYS EXPIRED & LOCKED 07-FEB-06 XDB EXPIRED & LOCKED 07-FEB-06 17 rows selected. SQL> alter user hibernate account lock; User altered. SQL> select username, account_status, lock_date from dba_users where username = 'HIBERNATE'; USERNAME ACCOUNT_STATUS LOCK_DATE ------------------------------ -------------------------------- --------- HIBERNATE LOCKED 31-MAR-10
Created by Dr. Xi on March 31, 2010 15:35:53
DBA_BLOCKERS displays a session if it is not waiting for a locked object but is holding a lock on an object for which another session is waiting. Column Datatype Description HOLDING_SESSION NUMBER Session holding a lock SQL> select * from dba_blockers; HOLDING_SESSION --------------- 364 SQL> select * from v$lock where sid = 364; ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK -------- -------- ---------- -- ---------- ---------- ---------- ---------- ---------- ---------- 978B3CBC 978B3CE8 364 AE 99 0 4 0 2531 0 00502BC4 00502BF4 364 TM 73541 0 3 0 2531 0 96CF4888 96CF48C8 364 TX 196617 151100 6 0 2531 1 SQL> -- find the session that's blocked SQL> select v1.* 2 from v$lock v1, v$lock v2 3 where v1.id1 = v2.id1 and ...
Created by Dr. Xi on March 31, 2010 15:14:39
Last update: March 31, 2010 15:17:46
DBA_WAITERS shows all the sessions that are waiting for a lock. Column Datatype Description WAITING_SESSION NUMBER The waiting session HOLDING_SESSION NUMBER The holding session LOCK_TYPE VARCHAR2(26) The lock type MODE_HELD VARCHAR2(40) The mode held MODE_REQUESTED VARCHAR2(40) The mode requested LOCK_ID1 VARCHAR2(40) Lock ID 1 LOCK_ID2 VARCHAR2(40) Lock ID 2 SQL> set lin 120 SQL> select * from dba_waiters; WAITING_SESSION HOLDING_SESSION LOCK_TYPE MODE_HELD --------------- --------------- -------------------------- ---------------------------------------- MODE_REQUESTED LOCK_ID1 LOCK_ID2 ---------------------------------------- ---------- ---------- 235 364 Transaction Exclusive Exclusive 196617 151100 SQL> Or join the v$session view to find out who it is: select w.waiting_session, w.mode_requested, s.username, s.machine, s.osuser from v$session s, dba_waiters w where s.sid = w.holding_session;