lunes, 28 de enero de 2008

Pool de conexiones Oracle con Spring

Es posible crear un pool de conexiones a la base de datos usando la siguiente configuración de beans. Utiliza commons-dbpc y los drivers de jdbc de Oracle. Los parámetros se cargan de un fichero .properties usando PropertyPlaceholderConfigurer de Spring.
No hay que olvidar devolver las conexiones al pool después de utilizarlas.

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>/WEB-INF/classes/jdbc.properties</value>
</property>
</bean>
<!--============================== -->
<!-- ==POOLED ORACLE DATASOURCE == -->
<!--============================== -->
<bean id="dataSource" class="org.apache.commons.dbcp.datasources.SharedPoolDataSource">
<property name="maxActive" ><value>${jdbc.maxActive}</value></property>
<property name="maxIdle" ><value>${jdbc.maxIdle}</value></property>
<property name="maxWait" ><value>${jdbc.maxWait}</value></property>
<property name="connectionPoolDataSource">
<bean class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
<property name="URL"><value>${jdbc.url}</value></property>
<property name="user"><value>${jdbc.username}</value></property>
<property name="password"><value>${jdbc.password}</value></property>
<property name="dataSourceName"><value></value></property>
</bean>
</property>
</bean>

viernes, 18 de enero de 2008

compilar flex usando ant


En lugar de usar el Flex Builder para compilar los swf, se puede invocar Flex SDK desde ANT consiguiendo el mismo resultado. Usar el plugin de eclipse para compilar flex es muy cómodo para el desarrollador, pero es preferible no subir al repositorio de versiones, los binarios generados en local, es mejor hacer la compilación en el build, al igual que se hace en java.
De esta manera es posible invocar al compilador java, pasándole los argumentos necesarios desde ant.

<!-- Uses jar files from Flex SDK to compile -->
<target name="compilemxml" >
<!-- Gets SWF name from mxml file name -->
<basename property="swfname" file="${filename}" suffix=".mxml"/>
<java jar="${FLEX_HOME}/lib/mxmlc.jar" fork="true" maxmemory="128m">
<jvmarg value="-Dapplication.home=${FLEX_HOME}"/>
<arg value="-compiler.services" />
<arg value="${DEPLOY_DIR}/WEB-INF/flex/services-config.xml" />
<arg value="-load-config" />
<arg value="${DEPLOY_DIR}/WEB-INF/flex/flex-config.xml" />
<arg value="-context-root"/>
<arg value="${context.root}"/>
<arg value="-source-path" />
<arg value="${SRC_DIR}"/>
<arg value="-output" />
<arg value="${OUT_DIR}/${swfname}.swf"/>
<arg value="${filename}" />
<arg value="-library-path" />
<arg value="${FLEX_HOME}/frameworks/libs" />
<arg value="${FLEX_HOME}/frameworks/locale/{locale}" />
<arg value="-locale" />
<arg value="en_US" />
<arg value="-licenses.license" />
<arg value="fds" />
<arg value="${fds}" />
</java>
</target>



Un argumento importante es -context-root ya que está referenciado en el services-config.xml:

http://{server.name}:{server.port}/{context.root}/messagebroker/amf


Creando un wrapper para nuestro swf generado: lo único que hay que hacer es coger la plantilla que viene con la FSDK y reemplazar los valores por los que nosostros queramos.

<!-- Create HTML wrapper -->
<target name="wrapper" depends="compilemxml" description="Creates the HTML wrapper">
<!-- Copy the html-wrapper dir except the index.template.html -->
<copy todir="${OUT_DIR}">
<fileset dir="${TEMPLATES_DIR}">
<exclude name="**/index.template.html" />
</fileset>
</copy>
<!-- Copy and rename the index.template.html -->
<copy file="${TEMPLATES_DIR}/index.template.html"
tofile="${OUT_DIR}/${swfname}.html" />

<!-- Replace placeholders in the html with our variables -->
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{width\}"
replace="100%"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{height\}"
replace="100%"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{title\}"
replace="${PROJECT_NAME}"
encoding="utf-8"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{version_major\}"
replace="9"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{version_minor\}"
replace="0"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{version_revision\}"
replace="0"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{application\}"
replace="${swfname}"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{bgcolor\}"
replace="white"/>
<replaceregexp
file="${OUT_DIR}/${swfname}.html"
flags="gs"
match="\$\{swf\}"
replace="${swfname}"/>
</target>


También es posible ejecutar Flex SDK, usando los ejecutables (.exe) del compilador que hay en el directorio bin.

Existen unos tasks para ant, aunque yo "he preferido" usar el compilador java.
http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks

jueves, 17 de enero de 2008

ORA-01461: can bind a LONG value only for insert into a LONG column



Si alguien se ha topado con este error de Oracle, relacionado con la longitud de los campos, puede que le venga bien probar lo que se comenta en este blog.
En su caso, la base de datos tenía un character set multibyte, es decir que puede utilizar varios bytes para representar un caracter, mientras que cliente estaba configurado con un character set single byte. Logicamente el "pete" viene cuando se supera el tamaño del campo en bytes.

http://oraclenotepad.blogspot.com/2007/05/ora-01461-can-bind-long-value-only-for.html

Movie & TV Show Preview Widget

Springframework.org -

We Heart Code

Eclipse Plugin Central