public DataSource dataSource() { String url = "jdbc:postgresql://localhost:5433/springJdbc"; String username = "postgres"; String pass = "postgres"; DataSource dataSource = new DriverManagerDataSource(url, username, pass); return dataSource; }
public DataSource dataSource() { String jndiName = "java:comp/env/jdbc/springJdbc"; JndiDataSourceLookup jndiDataSourceLookup = new JndiDataSourceLookup(); jndiDataSourceLookup.setResourceRef(true); DataSource dataSource = jndiDataSourceLookup.getDataSource(jndiName); return dataSource; }
By Jiří Čížek