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"));
}代码如上
是从数据库里读取图片的
conn = dataSource.getConnection();
执行到这行的时候就停顿了,不能向下执行了
这是什么问题
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"));
}代码如上
是从数据库里读取图片的
conn = dataSource.getConnection();
执行到这行的时候就停顿了,不能向下执行了
这是什么问题
解决方案 »
- 各位大侠帮忙看看这个算法应该怎么写,谢谢!
- 生成流水号的方法
- 求救,j2ee报错
- 谁能给一个MyEclipse4.1下hibernate3存数据库,取数据库(mysql)的例子啊
- tomcat5.0.19问题
- struts+ajax+json返回list查询结果求救- -
- apache tomcat 5.0.27
- java参数传递的时候是传值呢?还是传递参数了,
- 请问大虾:如何用JSP调用EJB?
- 还是spring管理action的问题啊,action不能实例化,求各位帮助。
- struts2问题???
- 把下载的fckeditor导入我的myclipse项目下报错,咋办,我已经把fck_docpros.html打上勾了
我看我的系统中有很多conn = dataSource.getConnection();
后没有没有conn.close();
连接池不用关闭连接吗?
applicationContext.xml 配置的dataSource
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@10.121.64.176:1521:orcl</value>
</property>
<property name="username">
<value>czjm</value>
</property>
<property name="password">
<value>czjm</value>
</property>
</bean>