Thursday, June 30, 2011

Notes from velocity 2011

Reference:
http://velocityconf.com/velocity2011/public/schedule/grid
http://www.youtube.com/view_play_list?p=C394849408B5F203

http://velocityconf.com/velocity2011/public/schedule/detail/18280 (Yahoo)
http://velocityconf.com/velocity2011/public/schedule/detail/17785 (Netflix)
http://velocityconf.com/velocity2011/public/schedule/detail/18087 (JS Engine)

Saturday, June 25, 2011

First php on macbook

Step 1: Enable Apache
System Preferences -> Sharing -> Web Sharing

Step 2: Enable PHP
/private/etc/apache2/httpd.conf -> LoadModule php5_module libexec/apache2/libphp5.so

Step 3:  Config PHP
cd /private/etc
sudo cp php.ini.default php.ini

Step 4: Restart apache
sudo apachectl restart

Step 5: phpinfo
<?php phpinfo(); ?>
http://localhost/~hj/info.php

Step 6: hello world
http://localhost/~hj/hello.php
<html>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<p>Hello World</p>'; ?>
 </body>
</html>
http://php.net/manual/en/tutorial.firstpage.php

Tuesday, June 21, 2011

streamstolob=false caused ORA-01407

Problem:
When insert large amount of characters into CLOB column of one Oracle db table, iBatis will throw ORA-01407 exception
com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in conf/sqlmaps/maps/EmailTemplate.xml. 
--- The error occurred while applying a parameter map. 
--- Check the UpdateSiteEmailTemplate-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: com.inet.ora.Ora4SQLException: [Oracle] #56 ORA-01407: cannot update ("TEST"."TESTTABLE"."MESSAGE") to NULL
[Oracle] #56
        at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
        at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
        at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
        at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:67)

Root Cause:
By default, inet JDBC driver implemented property streamstolob is set to false. Change stream parameter to CLOB/BLOB parameter to make it compatible with this data types. Without it, streams are only compatible until 4K bytes. Note: This property will work for i-net SERO, i-net SEROPTO and i-net ORANXO only.

For more info, check out i-net JDBC Driver Manual (from http://www.inetsoftware.de/)

Solution:
To use BLOB or CLOB data types larger than 4 KB for persistence using the Inet Oraxo JDBC Driver for Oracle Databases, you must set the database's streamstolob property value to true. There are two ways to set this property:
  1. append the properties to the URL like this:
    jdbc:inetora:192.168.0.110:1521?service=mydb.test.com&amp;failover=true&amp;streamstolob=true
  2. connectionProperties - A list of driver specific properties passed to the driver for creating connections. Each property is given as name=value, multiple properties are separated by semicolons. Default: no properties
    connectionProperties="streamstolob=true;failover=true"
Other interesting driver connection properties
  • queryTimeout - set default value for Statement.setQueryTimeout()
  • sduSize - the maximum packet size the driver is sending. default is 2920
  • failover - if set on true, the driver connects to alternative hosts, if connecting failed, default is false
  • loadbalance - if set on true, driver connects to one of the given hosts, default is "failover" value
  • initSQL - This query is executed once per connection