I am about so setup a Spring JDBC application using Servlet 3.0 and Spring JavaConfig, so there is no XML configuration involved.
The servlet configuration is as follows:
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Autowired
ServletContext servletContext;
@Bean
@Resource(name = "jdbc/DefaultDB")
public DataSource dataSource() {
final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
dsLookup.setResourceRef(true);
DataSource dataSource = dsLookup.getDataSource("java:comp/env/jdbc/DefaultDB");
return dataSource;
}
The deployment to both a local Java EE 6 Web Profile Server 2.71.8 and SAP HANA Cloud Platform says:
exceptionjavax.naming.NameNotFoundException: Name [DefaultDB] is not bound in this Context. Unable to find [DefaultDB].
Regarding the data source and JNDI stuff I would say that my application is setup like the application from the HCP tutorial
Adding Persistence With JDBC (Java Web SDK).
And that application can just be deployed and it works, without additional configuration.