java - How to bind a Data Source? -
i'm getting error -
org.springframework.beans.factory.beancreationexception: error creating bean name 'netlogsdao': injection of resource dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'abcdatasource' defined in com.kinsale.submclrmgr.config.dataconfig: bean instantiation via factory method failed; nested exception org.springframework.beans.beaninstantiationexception: failed instantiate [javax.sql.datasource]: factory method 'abcdatasource' threw exception; nested exception org.springframework.jdbc.datasource.lookup.datasourcelookupfailureexception: failed jndi datasource name 'datasource/abc'; nested exception javax.naming.namenotfoundexception: name [datasource/abc] not bound in context. unable find [datasource].
i trying figure out how bind data source, documentation i've found isn't helpful. there jnditemplate can use bind data source, passing parameters of string name , object object, nothing can find tells me object.
what object bind name of data source? , name of bean creating or name of resource in context.xml?
here bean -
@bean(name="abcdatasource") public datasource abcdatasource(){ jndidatasourcelookup jndi = new jndidatasourcelookup(); jndi.setresourceref(true); return jndi.getdatasource("datasource/abc");
here use of bean -
@resource(name="abcdatasource") private datasource ds;
here context.xml entry (i have correct username , password)-
<resource name="datasource/abc" auth="container" type="com.mysql.jdbc.jdbc2.optional.mysqldatasource" factory="org.apache.naming.factory.beanfactory" url="jdbc:mysql://abc/db_netlogs" />
in order work, following dependency needs in pom.
<dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.17</version> </dependency>
as added that, worked.
Comments
Post a Comment