Friday, June 24, 2011

Setting CLOB in Hibernate annotation

Setting CLOB in Hibernate annotation

@Lob @Basic(fetch=FetchType.EAGER)
@Column(name = "news")      
   private String news;

Wednesday, June 22, 2011

Specify username, password and timeout in jboss webservice client

Specify the username, password and timeout ,in a jboss web service client.


In your generated client class , getting Soap instance method ,
eg:


public TESTGenericDataAccessSoap getTESTGenericDataAccessSoap(){
{
TESTGenericDataAccessSoap soap = super.getPort(TESTGenericDataAccessSoap , TESTGenericDataAccessSoap .class);
        BindingProvider bp = (BindingProvider)soap;
         Stub stub = (Stub)soap;
         stub._setProperty(StubExt.PROPERTY_CLIENT_TIMEOUT, 10); //Time out
        bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jijo");//Username
        bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "jijo");//Password
        return soap;
}

The import classes are given,

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.Stub;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
import org.jboss.ws.core.StubExt;

Friday, June 10, 2011

Div is going behind the SWF

When the div is going behind the SWF, give the following paramter 

<param name="wmode" value="transparent" />
eg:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
            id="Test" width="100%" height="100%"
            codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
            <param name="movie" value="Test.swf" />
            <param name="quality" value="high" />
            <param name="bgcolor" value="#869ca7" />
            <param name="allowScriptAccess" value="sameDomain" />
            <param name="wmode" value="transparent" />
            <embed src="Test.swf" quality="high" bgcolor="#869ca7"
                width="100%" height="100%" name="Test" align="middle"
                play="true"
                loop="false"
                quality="high"
                allowScriptAccess="sameDomain"
                wmode="transparent"
                type="application/x-shockwave-flash"
                pluginspage="http://www.adobe.com/go/getflashplayer">
            </embed>
    </object>

Sunday, May 29, 2011

Change SVN password or remove stored passord from SVN eclipse plugin

In windows;
remove the following folder
C:\Documents and Settings\…..\Application Data\Subversion\auth\
eg: C:\Documents and Settings\jijo\Application Data\Subversion\auth 
Some times 'Application Data' is hidden.Please enable 'show hidden files' in file system.

Then Remove the auth folder.
In the auth folder you can find the following folders,
svn.simple
svn.ssl.client-passphrase
svn.ssl.server
svn.username


In linux :
~/.subversion/auth
This folder is hidden.Please enable the 'show hidden files'  in file system.Then remove the auth folder.

After the next saving from eclipse to SVN , password option will come.

NB: If you are not found the above path, search the auth folder,and check whether is SVN related and then remove that folder.
 







Thursday, February 24, 2011

increment a value using jstl c tag

<c:set var="numberOfRows" value="0"/><c:set var="numberOfRows" value="${numberOfRows+1}"/>
<c:out value="${numberOfRows}"/>

Wednesday, February 16, 2011

Read data from file using apache commons.io

package com.jijo;
import org.apache.commons.io.FileUtils;
import java.io.File;
//use commons-io-1.3.2.jar 
//download the above jar and include that in your class path.

class FileTest{

public String getFileData(String fileName){ //eg: c:/jijo/test.txt
String xmlData = null;
File file = new File(fileName);
        try{
        xmlData = FileUtils.readFileToString(file);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
return xmlData;
}

}

Code Complete: A Practical Handbook of Software Construction

Visualage for Java Enterprise Edition 

Wednesday, April 21, 2010

Html contents using h:outputText

<h:outputText value="#{testBean.htmlText}"
               escape="false" />

 Generate your html contents in testBean.htmlText

Tuesday, April 20, 2010

The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit



If you are using <%@ include file="test.jsp" %>(static include),
replace this to <jsp:include page="test.jsp" /> (dynamic include).

Wednesday, April 14, 2010

jndi configuration in Jboss server

Jijo-ds.xml (put this file in jboss deploy folder)

<datasources>
  <local-tx-datasource>
    <jndi-name>jijoDS</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/jijo</connection-url>

    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>root</user-name>
    <password>mysql</password>
    <!-- you can include connection properties that will get passed in

     the DriverManager.getConnection(props) call-->
    <!-- look at your Driver docs to see what these might be -->
    <connection-property name="char.encoding">UTF-8</connection-property>

    <transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isolation>

    <!--pooling parameters-->
    <min-pool-size>10</min-pool-size>
    <max-pool-size>30</max-pool-size>

    <blocking-timeout-millis>5000</blocking-timeout-millis>
    <idle-timeout-minutes>1</idle-timeout-minutes>
    <!-- sql to call when connection is created -->
    <new-connection-sql>select 1</new-connection-sql>

   

    <!-- sql to call on an existing pooled connection when it is obtained from pool -->
    <check-valid-connection-sql>select 1</check-valid-connection-sql>
   
    <set-tx-query-timeout></set-tx-query-timeout>
    <query-timeout>300</query-timeout> <!-- maximum of 5 minutes for queries -->

  </local-tx-datasource>
</datasources>

in your application WEB-INF/jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
        <security-domain>java:/jaas/jmx-console</security-domain> 
         <resource-ref> 
       <res-ref-name>jijoDS</res-ref-name>
       <jndi-name>java:/jijoDS</jndi-name>
   </resource-ref>    
</jboss-web>

in web.xml

<resource-ref>
        <res-ref-name>jijoDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>



in applicationContext.xml you are using Spring-Hibernate combination


<bean id="dataSource" class="org.springframework.
jndi.JndiObjectFactoryBean" singleton="true">
     <property name="jndiName">
        <value>java:/jijoDS</value>
     </property>
</bean>

<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean" >
<property name="properties">
<props>
<prop key="hibernate.dialect">dialect name</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
<prop key="hibernate.connection.datasource">java:/comp/env/jdbc/jijoDS</prop>
</props>
</property>
</bean>

DataBase connection configuration in Spring-Hibernate(applicationContext.xml)

in jdbc.properties  

#for Oracle
#jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
#jdbc.url=jdbc:oracle:thin:@192.168.0.69:1521:jijo
#jdbc.username=jijo
#jdbc.password=jijo
#hibernate.dialect=org.hibernate.dialect.Oracle10gDialect


#for MYSQL
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/jijo
jdbc.username=root
jdbc.password=jijo
hibernate.dialect=org.hibernate.dialect.MySQLDialect

hibernate.c3p0.initialPoolSize=10
hibernate.c3p0.minPoolSize=5
hibernate.c3p0.maxPoolSize=25
hibernate.c3p0.acquireRetryAttempts=10
hibernate.c3p0.acquireIncrement=5
hibernate.c3p0.idleConnectionTestPeriod=3600
hibernate.c3p0.preferredTestQuery=SELECT 1;
hibernate.c3p0.testConnectionOnCheckin=false
hibernate.c3p0.maxConnectionAge=100
hibernate.c3p0.maxIdleTime=120


in applicationContext.xml

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/> 
<property name="initialPoolSize"><value>${hibernate.c3p0.initialPoolSize}</value></property>
<property name="minPoolSize"><value>${hibernate.c3p0.minPoolSize}</value></property>
<property name="maxPoolSize"><value>${hibernate.c3p0.maxPoolSize}</value></property>
<property name="acquireRetryAttempts"><value>${hibernate.c3p0.acquireRetryAttempts}</value></property>
<property name="acquireIncrement"><value>${hibernate.c3p0.acquireIncrement}</value></property>
<property name="idleConnectionTestPeriod"><value>${hibernate.c3p0.idleConnectionTestPeriod}</value></property>
<property name="maxIdleTime"><value>${hibernate.c3p0.maxIdleTime}</value></property>
<property name="maxConnectionAge"><value>${hibernate.c3p0.maxConnectionAge}</value></property>
<property name="preferredTestQuery"><value>${hibernate.c3p0.preferredTestQuery}</value></property>
<property name="testConnectionOnCheckin"><value>${hibernate.c3p0.testConnectionOnCheckin}</value></property>
</bean>


<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="hibernateProperties">
            <props>

                 <prop key="hibernate.dialect">
                    ${hibernate.dialect}
                </prop>

                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.cglib.use_reflection_optimizer">
                    true
                </prop>
                <prop key="hibernate.cache.provider_class">
                    org.hibernate.cache.HashtableCacheProvider
                </prop>
                <prop key="hibernate.c3p0.acquire_increment">${hibernate.c3p0.acquireIncrement}</prop>
                <prop key="hibernate.c3p0.idle_test_period">${hibernate.c3p0.idleConnectionTestPeriod}</prop>
                <prop key="hibernate.c3p0.timeout">${hibernate.c3p0.maxIdleTime}</prop>
                <prop key="hibernate.c3p0.max_size">${hibernate.c3p0.maxPoolSize}</prop>
                <prop key="hibernate.c3p0.min_size">${hibernate.c3p0.minPoolSize}</prop>
                <prop key="hibernate.show_sql">false</prop>
            </props>
        </property>
    </bean>