/****/
packagecom.autoyolConsole.service.cpic;importjava.sql.Connection;importjava.util.Map;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.beans.factory.annotation.Qualifier;importorg.springframework.jdbc.core.JdbcTemplate;importorg.springframework.stereotype.Service;importcom.mchange.v2.c3p0.ComboPooledDataSource;/***@authorxx.xx
* @function sqlserver数据库查询操作类
* @date 2017年11月6日
*@version
*/@Servicepublic classCpicRenyunService {privateJdbcTemplate jdbcTemplateRenyun;
@Autowired
@Qualifier("ds")privateComboPooledDataSource ds;
publicJdbcTemplate getJdbcTemplateRenyun() {returnjdbcTemplateRenyun;
}public voidsetJdbcTemplateRenyun(JdbcTemplate jdbcTemplateRenyun) {
this.jdbcTemplateRenyun =jdbcTemplateRenyun;
}public voidqueryAutoInfor005ById(String id){try{
System.out.println("DS="+ds);
java.sql.DatabaseMetaData md=ds.getConnection().getMetaData();
System.out.println("s11="+md.getDriverName());
System.out.println("s21="+md.getURL());
System.out.println("s31="+md.getUserName());boolean f =jdbcTemplateRenyun.getDataSource().getConnection().isClosed();
Connection conn=jdbcTemplateRenyun.getDataSource().getConnection();
String s1=conn.getMetaData().getDriverName();
String s2=conn.getMetaData().getURL();
String s3=conn.getMetaData().getUserName();
System.out.println("f="+f);
System.out.println("s1="+s1);
System.out.println("s2="+s2);
System.out.println("s3="+s3);
Map map = jdbcTemplateRenyun.queryForMap("select * from auto_infor_005 where auto_inf05_id=1372");
System.out.println("查询返回结果:" +map);
}catch(Exception e) {
e.printStackTrace();
}
}
}