如何在Spring Boot中配置Sybase SQLanywhere 16数据源?

问题描述 投票:0回答:1

我想声明一个数据源,它实际上是一个Sybase SQLAnywhere 16数据库。我已经使用实现了[[javax.sql.Datasource接口的com.mysql.jdbc.jdbc2.optional.MysqlDataSourceMY SQL做同样的事情。

@Configuration @PropertySource("classpath:db.properties") public class DbConfig { @Autowired private Environment env; @Bean public DataSource getDataSource() { try { MysqlDataSource mysqlDS = null; mysqlDS = new MysqlDataSource(); mysqlDS.setURL(env.getProperty("MYSQL_DB_URL")); mysqlDS.setUser(env.getProperty("MYSQL_DB_USERNAME")); mysqlDS.setPassword(env.getProperty("MYSQL_DB_PASSWORD")); } catch (IOException e) { e.printStackTrace(); } return mysqlDS; } }
我想知道。对于

Sybase SQLAnywhere16

,需要哪个jar以及如何像上面的代码一样进行配置。实际需要此数据源才能实现下面的代码。 @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(dataSource)...... }
sybase spring-jdbc sqlanywhere
1个回答
0
投票
我已通过以下代码完成。

@Bean public DataSource getDataSource() { SybDataSource mysqlDS = new SybDataSource(); try { mysqlDS.setPortNumber(properties.getProperty("db_port")); mysqlDS.setServerName(properties.getProperty("db_host")); mysqlDS.setUser(properties.getProperty("db_username")); mysqlDS.setPassword(properties.getProperty("db_password")); mysqlDS.setDatabaseName(properties.getProperty("db_name")); } catch(Exception e) { e.printStackTrace(); } return mysqlDS; }

© www.soinside.com 2019 - 2024. All rights reserved.