java web项目中java.lang.StackOverflowError报这个错 怎么解决 在线等 急!

罒Mr.L 2017-05-21 05:10:24
...全文
2288 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
罒Mr.L 2017-05-21
  • 打赏
  • 举报
回复
package cn.Shopping.dao; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import javax.naming.Context; import javax.naming.InitialContext; import javax.sql.DataSource; /** * 数据访问工具类 * @version 1.1 * @author happy * */ public class BaseDao { // 01. 基础内容的准备 public static final String driver="com.mysql.jdbc.Driver"; public static final String url="jdbc:mysql://localhost:3306/easybuy"; public static final String username="root"; public static final String password=""; //02, 接口对象的准备 Connection con=null; PreparedStatement ps=null; public ResultSet rs=null; /** * 01.写一个用户获取到一个连接对象的方法,方法的返回值是Connection类型 * @return 连接对象 * @throws Exception */ public Connection getConnection() throws Exception{ Class.forName(driver); //什么条件下,构建connection对象 if (con==null||con.isClosed()) { con=DriverManager.getConnection(url, username, password); } //同志们碰到一个 return con; } public Connection getConnectionSD() throws Exception { Context ctx= new InitialContext(); DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/easybuy"); Connection con=ds.getConnection(); return con; } /** * 执行查询操作 目的:返回一个读取器 * @param sql sql语句 * @param objs 参数列表 * @return 读取器对象 * @throws Exception */ public ResultSet executeQuery(String sql,Object... objs) throws Exception{ con=getConnection(); ps = con.prepareStatement(sql); for (int i = 0; i < objs.length; i++) { ps.setObject(i+1, objs[i]); } rs= ps.executeQuery(); return rs; } /** * 执行增删该操作 * @param sql sql语句 * @param objs 参数列表 * @return 受影响行数 * @throws Exception */ public int executeUpdate(String sql,Object... objs) throws Exception{ con=getConnection(); ps = con.prepareStatement(sql); for (int i = 0; i < objs.length; i++) { ps.setObject(i+1, objs[i]); } int count = ps.executeUpdate(); return count; } /** * 回收连接资源 * @throws Exception */ public void closeAll() throws Exception{ //倒着回收 if(rs!=null){ rs.close(); } if (ps!=null) { ps.close(); } if(con!=null){ con.close(); } } }
李德胜1995 2017-05-21
  • 打赏
  • 举报
回复
栈溢出,递归了吧???方法调用自己。。,,BaseDao贴出来看看

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧