在spring中获取Connection 的方法
javax.servlet.ServletContext servletContext=request.getSession().getServletContext(); org.springframework.web.context.WebApplicationContext webApplicationContext = org.springframework.web.context.support.WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext);
DataSource dataSource = (DataSource)webApplicationContext.getBean("dataSource");
Connection conn = null;
ResultSet rs = null;
Statement stmt = null;
String SQLString = "";
//定义查询语句 InputStream in = null; //定义输入流
int len = 10 * 1024 * 1024; //定义字符数组长度
try {
SQLString = "select d402_02 from d402 where d402_01 ='" + request.getParameter("id")+"'";
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(SQLString);
} catch (Exception e) {
System.out.println("相片-数据库操作 编号:"+request.getParameter("id"));
}