0

I am trying to connect a Spring MVC 4 application to MY Sql local BBDD.

This is the files:

Spring MVCConfiguration File:

@Bean
public DataSource dataSource() throws Exception {
     Context cts = new InitialContext();
     DataSource dts = (DataSource) cts.lookup("java:/comp/env/jdbc/etielaBBDD");

     return dts;
}

Tomcat Context.xml:

<ResourceLink name="jdbc/etielaBBDD"
            global="jdbc/BBDD"
            auth="Container"
            type="javax.sql.DataSource" />

Tomcat Server XML:

<Resource name="jdbc/BBDD" global="jdbc/BBDD" auth="Container" type="javax.sql.DataSource"
     username="XXXXXX"
     password="XXXXXX"
     driverClassName="com.mysql.jdbc.Driver"
     url="jdbc:mysql://localhost:3306/confluenceuseUnicode=true&amp;characterEncoding=utf8"
     maxActive="15"
     maxIdle="7"
     defaultTransactionIsolation="READ_COMMITTED"
     validationQuery="Select 1" />

And, when I Start Tomcat, this error appears:

javax.naming.NameNotFoundException: Name jdbc/BBDD is not bound in this context

I am two days trying to solve this error with no solution. Any idea? Thanks.

Ildelian
  • 1,278
  • 5
  • 15
  • 38
  • hi, have you got the mysql reference lib in your tomcat/lib folder. You will need to copy it. mysql-connector-java-x.x.x.jar. You can find one : http://www.mysql.com/products/connector/ – jeorfevre May 15 '15 at 12:46
  • also if you have a web.xml do include this : MySQL Datasource example jdbc/BBDD javax.sql.DataSource Container – jeorfevre May 15 '15 at 12:48
  • Thanks. I already have the connector instaled. I try to put the resource in my Web.xml, but the problem persist, – Ildelian May 15 '15 at 13:14
  • http://stackoverflow.com/questions/26727441/in-spring-tomcat-which-configuration-file-do-jndi-lookups-refer-to/26738345#26738345, You can check this SO question........ I believe / should be removed before comp cts.lookup("java:comp/env/jdbc/etielaBBDD") – Karthik Prasad May 15 '15 at 13:18
  • I have a Annotation configuration, i dont have any XML file, but thanks for the info. – Ildelian May 15 '15 at 13:41

0 Answers0