0
我正在使用spring jdbc。我正在使用下面的代码来获得jdbc连接如何访问连接url
public void setDataSource(DataSource dataSource){
this.dataSource = dataSource;
setJdbcTemplate(new JdbcTemplate(this.dataSource));
setNamedParamdbcTemplate(new NamedParameterJdbcTemplate(this.dataSource));
if(connectionUrl==null){
Connection con;
try {
con = getJdbcTemplate().getDataSource().getConnection();
connectionUrl = con.getMetaData().getURL();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
但我收到以下异常。
配置阻塞超时 (0 [毫秒])内没有可用的管理的连接
我具有由调试代码采取了打印。以上是getJdbcTemplate().getDataSource()
代码的输出。
Click here for the image 如果我写了getJdbcTemplate().getDataSource().getConnection();
以下例外即将到来。如何访问图像中存在的 connectionURL。
配置阻塞超时时间内没有可用的受管连接(0 [毫秒])