Notes by Dr. Xi

Displaying notes 91 - 100
Created by Dr. Xi on October 23, 2009 23:26:44
<c:choose> <c:when test="${case == 1}"> Case one </c:when> <c:when test="${case == 2}"> Case two </c:when> <c:otherwise> Everything else </c:otherwise> </c:choose>
Created by Dr. Xi on October 18, 2009 04:25:25
start python with python -v import django and print version: Type "help", "copyright", "credits" or "license" for more information. >>> import django import django # directory /usr/local/python/lib/python2.5/site-packages/django # /usr/local/python/lib/python2.5/site-packages/django/__init__.pyc matches /usr/local/python/lib/python2.5/site-packages/django/__init__.py import django # precompiled from /usr/local/python/lib/python2.5/site-packages/django/__init__.pyc >>> print django.VERSION (1, 0, 2, 'final', 0) >>>
Created by Dr. Xi on October 09, 2009 19:27:22    Last update: October 09, 2009 19:30:01
PL/SQL code from Pandazen : CREATE OR REPLACE FUNCTION GET_INSERT_SCRIPT(V_TABLE_NAME VARCHAR2) RETURN VARCHAR2 AS B_FOUND BOOLEAN := FALSE; V_TEMPA VARCHAR2 (8000); V_TEMPB VARCHAR2 (8000); V_TEMPC VARCHAR2 (255); BEGIN FOR TAB_REC IN (SELECT TABLE_NAME FROM ALL_TABLES WHERE TABLE_NAME = UPPER (V_TABLE_NAME)) LOOP B_FOUND := TRUE; V_TEMPA := 'select ''insert into ' || TAB_REC.TABLE_NAME || ' ('; FOR COL_REC IN (SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = TAB_REC.TABLE_NAME ORDER BY COLUMN_ID) LOOP IF COL_REC.COLUMN_ID = 1 THEN V_TEMPA := V_TEMPA || '''||chr(10)||'''; ELSE V_TEMPA := V_TEMPA || ',''||chr(10)||'''; V_TEMPB := V_TEMPB || ',''||chr(10)||'''; END IF; V_TEMPA := V_TEMPA || COL_REC.COLUMN_NAME; IF INSTR (COL_REC.DATA_TYPE, 'CHAR') > 0 THEN V_TEMPC := '''''''''||' || COL_REC.COLUMN_NAME || '||'''''''''; ELSIF INSTR (COL_REC.DATA_TYPE, 'DATE') > 0 THEN V_TEMPC := '''to_date(''''''||to_char(' || COL_REC.COLUMN_NAME || ...
Created by Dr. Xi on October 09, 2009 03:39:22    Last update: October 09, 2009 19:25:50
Luhn algorithm in Python just for the heck of it. def doLuhn(s, evenPos): s = str(s) sum = 0 for d in reversed(s): d = int(d) assert 0 <= d <= 9 if evenPos: d *= 2 if d > 9: d = (d % 10) + 1 sum += d evenPos = not evenPos return sum def luhnValidation(n): return doLuhn(n, False) % 10 == 0 def generateCheckDigit(n): return 10 - (doLuhn(n, True) % 10) if __name__ == '__main__': import sys if len(sys.argv) < 2: print "%s <number> [g] " % sys.argv[0] sys.exit(1) elif len(sys.argv) == 2: n = sys.argv[1] if luhnValidation(n): print "%s is valid" % n else: print "%s is not valid" % n else: n = sys.argv[1] print "%s%s" % (n, generateCheckDigit(n))
Created by Dr. Xi on October 09, 2009 02:56:44
The Luhn algorithm is used to validate credit card numbers. This class provides two methods: one to validate that a number passes the Luhn algorithm validation, the other to generate a check digit that makes a number pass the Luhn validation. public class Luhn { public static void main(String[] args) { if (args.length < 1) { System.err.println("Usage: number [g] "); System.exit(1); } String n = args[0]; if (args.length == 2) { System.out.println(n + generateDigit(n)); } else if (isValidNumber(n)) { System.out.println(n + " is valid"); } else { System.out.println(n + " is NOT valid"); } } private static boolean isValidNumber(String s) { return doLuhn(s, false) % 10 == 0; } private static String generateDigit(String s) { int digit = 10 - doLuhn(s, true) % 10; return ...
Created by Dr. Xi on September 20, 2009 16:52:19    Last update: March 22, 2010 01:28:49
When I assemble a session bean without the proprietary deployment descriptor ( orion-ejb-jar.xml ), OC4J generates one like this (as can be seen from the OC4J management console): <?xml version="1.0" encoding="utf-8"?> <orion-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-ejb-jar-10_0.xsd" deployment-version="10.1.3.3.0" deployment-time="123d598f9ca" schema-major-version="10" schema-minor-version="0" > <enterprise-beans> <session-deployment name="SimpleBean" location="SimpleBean" local-location="simpleEjb_SimpleBeanLocal" persistence-filename="SimpleBean.test_default_group_1"> </session-deployment> </enterprise-beans> <assembly-descriptor> <default-method-access> <security-role-mapping name="&lt;default-ejb-caller-role&gt;" impliesAll="true" /> </default-method-access> </assembly-descriptor> </orion-ejb-jar> So I use this code to lookup the EJB: import javax.naming.Context; import javax.naming.InitialContext; . . . Context ctx = new InitialContext(); Simple s = (Simple) ctx.lookup("simpleEjb_SimpleBeanLocal"); OC4J throws ClassCastException : java.lang.ClassCastException: com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.ejb.StatelessSessionDefaultLocalHomeImpl The JNDI browser (OC4J container home -> Administration -> JNDI browser) shows that the name simpleEjb_SimpleBeanLocal is bound to: com.evermind.server.ejb.StatelessSessionDefaultLocalHomeImpl Solution: Change the local name in the OC4J generated orion-ejb-jar.xml to ...
Created by Dr. Xi on September 13, 2009 03:30:24
Select the Path tool from the Tools menu Start clicking on the picture to drop vertices on the picture Hold CTRL and click on the first vertex to close the path Stroke the path (Edit->Stroke Path), or convert the path to selection (Click the "Create Selection from Path" button)
Created by Dr. Xi on September 10, 2009 04:30:38    Last update: September 10, 2009 04:38:14
From the EJB3 spec: A logical name is assigned to each enterprise bean in the ejb-jar file. There is no architected relationship between this name and the JNDI name that the Deployer will assign to the enterprise bean. The Bean Provider can specify the enterprise bean’s name in the ejb-name element. If the enterprise bean’s name is not explicitly specified in metadata annotations or in the deployment descriptor, it defaults to the unqualified name of the bean class .
Created by Dr. Xi on August 20, 2009 04:03:07
Use alter package to recompile a PL/SQL package. SQL> alter package UTIL compile; Warning: Package altered with compilation errors. SQL> show errors; Errors for PACKAGE UTIL: LINE/COL ERROR -------- ----------------------------------------------------------------- 106/3 PL/SQL: Declaration ignored 106/29 PLS-00201: identifier 'ID_TYPE' must be declared SQL> SQL> SQL> select line, position, text from user_errors where name = 'UTIL' order by line; LINE POSITION ---------- ---------- TEXT -------------------------------------------------------------------------------- 106 3 PL/SQL: Declaration ignored 106 29 PLS-00201: identifier 'ID_TYPE' must be declared SQL>
Created by Dr. Xi on August 20, 2009 03:24:25    Last update: August 20, 2009 03:25:55
I get this error using PL/SQL to enqueue a JMS message in Oracle XE: Oracle: PLS-00302: component 'CONSTRUCT' must be declared . Following an advice I found on the web , I ran the script "$ORACLE_HOME/rdbms/admin/prvtaqal.plb" as SYS in sqlplus. That worked even though I got a bunch of errors running the script: Warning: Package created with compilation errors. Errors for PACKAGE DBMS_JMS_PLSQL: LINE/COL ERROR -------- ----------------------------------------------------------------- 131/3 PL/SQL: Declaration ignored 138/3 PLS-00311: the declaration of "oracle.jms.SelectorToRule.convert_jms_selector(java.lang.String, int, boolean, java.lang.String[]) return int" is incomplete or malformed 143/3 PL/SQL: Declaration ignored 148/3 PLS-00311: the declaration of "oracle.jms.plsql.ExceptionHandler.get_exception(oracle.sql.STRUC T[], int[]) return int" is incomplete or malformed LINE/COL ERROR -------- ----------------------------------------------------------------- 154/3 PL/SQL: Declaration ignored 161/3 PLS-00311: the declaration of "oracle.jms.plsql.BytesMsgHandler.prepare(int, int[], byte[], oracle.sql.BLOB) return int" is incomplete ...
Previous  5 6 7 8 9 10 11 12 13 14 Next