删除实现不了,数据库已经连上了
at com.wyk.ConnDB.executeUpdata(ConnDB.java:67)
at org.apache.jsp.goods_005fdelete_jsp._jspService(goods_005fdelete_jsp.java:81)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)




package com.wyk;

import java.io.InputStream;
import java.sql.*;
import java.util.Properties;

public class ConnDB {
public Connection conn = null;
public Statement stmt = null;
public ResultSet rs = null;
private static Statement st = null; //设置Statement类的对象
private static String propFileName = "/com/connDB.properties"; //指定资源文件保存的位置
private static Properties prop = new Properties();
private static String dbClassName ="com.mysql.jdbc.Driver";
private static String dbUrl =
"jdbc:mysql://127.0.0.1:3306/db_wuliu?user=root&password=mysql&useUnicode=true";
public ConnDB(){
try {
InputStream in=getClass().getResourceAsStream(propFileName);
prop.load(in); //通过输入流对象加载Properties文件
dbClassName = prop.getProperty("DB_CLASS_NAME"); //获取数据库驱动
dbUrl = prop.getProperty("DB_URL",
"jdbc:mysql://127.0.0.1:3306/db_wuliu?user=root&password=mysql&useUnicode=true");
}
catch (Exception e) {
e.printStackTrace(); //输出异常信息
}
}

  public static Connection getConnection() {
    Connection conn = null;
    try {
      Class.forName(dbClassName).newInstance();
      conn = DriverManager.getConnection(dbUrl);
    }
    catch (Exception ee) {
      ee.printStackTrace();
    }
    if (conn == null) {
      System.err.println(
          "警告: DbConnectionManager.getConnection() 获得数据库链接失败.\r\n\r\n链接类型:" +
          dbClassName + "\r\n链接位置:" + dbUrl);
    }
    return conn;
  }

/*
 * 功能:执行查询语句
 */
public ResultSet executeQuery(String sql) {
    try {
        conn = getConnection();
        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        rs = stmt.executeQuery(sql);
    } catch (SQLException ex) {
        System.err.println(ex.getMessage());
    }
    return rs;
}

/*
 * 功能:执行更新操作
 */
public boolean executeUpdata(String sql) {
    try {
        st = conn.createStatement();                            //创建声明对象连接
        ((ConnDB) st).executeUpdata(sql);                           //执行添加、修改、删除操作
        return true;                                   //如果执行成功则返回true
    } catch (Exception e) {
        e.printStackTrace();
    return false;                                     //如果执行成功则返回false
    }}
/*
 * 功能:关闭数据库的连接
 */
public void close() {
    try {
        if (rs != null) {
            rs.close();
        }
        if (stmt != null) {
            stmt.close();
        }
        if (conn != null) {
            conn.close();
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}

}

0

1个回答

com.wyk.ConnDB.executeUpdata 方法贴出来看看啊

0
KAIKAI_ING
KAIKAI_ING 已经贴出来了 ,大神再帮我看看啊
接近 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!