Using datasource defined in blueprint in java to access oracle db -
below datasource
<bean id="datasource" class="oracle.jdbc.pool.oracledatasource" destroy-method="close"> <property name="url" value="jdbc:oracle:thin:@${host}:${port}:${dbname}"/> <property name="user" value="${user}"/> <property name="password" value="${pass}"/> </bean> <service ref="datasource" interface="javax.sql.datasource"> <service-properties> <entry key="osgi.jndi.service.name" value="jdbc/oracleds"/> <entry key="datasource.name" value="oracleds"/> </service-properties> </service> <bean id="logtooracledb" class="com.beans.logtooracledb"> <property name="datasource" ref="datasource" /> </bean>
i want use in bean file called logtooracledb
public class logtooracledb { protected static datasource datasource; public void test(exchange exchange) throws sqlexception { connection con = datasource.getconnection(); statement stmt = con.createstatement(); ............... }
im getting null pointer exception while getting connection datasource
since null. can me out lookingup datasource??
datasource = (datasource)context.lookup(jndiname);
you have use this,otherwise create combopool , try that
Comments
Post a Comment