0

I have following applicationContext.properties file. I am able to connect and execute Oracle Sql query while datasource is creayted over JNDI defnned at AS Glassfish. However when I defined datasource using org.apache.commons.dbcp.BasicDataSource" defintion I am having following error (ORA-00911: invalid character).

The interesting point is that I have tried both definition with Mysql Db,it works. What am I doing wrong?

Mysql:

JNDI way : Works

Direc Db Connection: Works

Oracle:

JNDI way : Works

Direct Db Connection: Does not work

applicationContext.properties file

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="${sim.jndi}" />
</bean>


<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${db.driver}"/>
    <property name="url" value="${db.url}"/>
    <property name="username" value="${db.username}"/>
    <property name="password" value="${db.password}"/>
    <property name="initialSize" value="${db.initialSize}"/>
    <property name="minIdle" value="${db.minIdle}"/>
    <property name="maxIdle" value="${db.maxIdle}"/>
    <property name="maxActive" value="${db.maxActive}"/>
    <property name="validationQuery" value="${db.validationQuery}"/>
    <property name="testOnBorrow" value="false"/>
    <property name="testWhileIdle" value="true"/>
    <property name="timeBetweenEvictionRunsMillis" value="1200000"/>
    <property name="minEvictableIdleTimeMillis" value="1800000"/>
    <property name="numTestsPerEvictionRun" value="5"/>
    <property name="defaultAutoCommit" value="true"/>
</bean>

Error I am having:

)
javax.el.ELException: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC
Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableCo
nnectionFactory (ORA-00911: invalid character
)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:279)
        at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionList
ener.java:149)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:818)
        at javax.faces.component.UICommand.broadcast(UICommand.java:300)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.jav

2 Answers 2

1

I think you had a problem in the

<property name="validationQuery" value="${db.validationQuery}"/>

can you check if there is any special character. Thanks

Sign up to request clarification or add additional context in comments.

Comments

0

I have changed my datasource definition as follow, and it works.

<bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">

        <property name="driverClassName" value="${db.driver}" />
        <property name="url" value="${db.url}" />
        <property name="username" value="${db.username}" />
        <property name="password" value="${db.password}" />
    </bean>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.