Thursday, April 29, 2010

Insert for multiple records


insert into ce_antennaSocket(platformName, socketID, socketName, radioBandID) values
('AP2600', '0', 'Left Antenna Type', 0),
('AP2600', '1', 'Right Antenna Type', 0),
('AP2650', '0', 'Top Left Antenna Type', 0),
('AP2650', '1', 'Bottom Left Antenna Type', 0),
('AP2650', '2', 'Top Right Antenna Type', 0),
('AP4102', '1', 'Right Antenna Type', 1);

It has much much better performance than split into multiple insert statements. To insert 15k records, it took less than 1 second. Otherwise, it took 8 minutes.

Wednesday, April 28, 2010

Class vs. Classloader getResouceAsStream

In bk.sar -
conf/bkConfigSchema.sql
com.xyz.BkWirelessMgr

For classloader.getResouceAsStream(), all names are absolute, no leading "/". For class.getResourceAsStream(), it has relative and absolute path. But relative means starting from the class's package, i.e., without the leading "/", it will search com.xyz/conf/bkConfigSchema.sql, not found and return null.

Then in BkWirelessMgr class, to load the sql,

getClass().getResourceAsStream("/conf/bkConfigSchema.sql");
getClass().getClassLoader().getResourceAsStream("conf/bkConfigSchema.sql");

Note that "/" is used here instead of File.Separator which doesn't work.

Friday, April 23, 2010

ParentAppContext

The bk-core.spring is deployed by Spring Deployer and its applicatonContext could be parent context of the webApplicatonContext (loaded by ContextLoaderListener) in bk-config-engine.war to share the beans in bk-core. To configure this:

1. In bk-core's jboss-spring.xml


BeanFactory=(java:/bkCore);

Then the beanFactory will be bound to JNDI in unserialized form with the given name by Spring deployer.

2. In bk-config-engine.war's web.xml


parentContextKey
bkCoreAppContext


3. Add beanRefContext.xml in bk-config-engine.war (located in classpath)

<jee:jndi-lookup id="bkCoreAppContext" jndi-name="java:/bkCore"/>

Thursday, April 8, 2010

Choose XML Parser


System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");