java.sql.SQLException:Can not issue data manipulation statements with executeQuery(),executequery

來源:互聯網
上載者:User

java.sql.SQLException:Can not issue data manipulation statements with executeQuery(),executequery

1、錯誤描述

java.sql.SQLException:Can not issue data manipulation statements with executeQuery()


2、錯誤原因

Class.forName("com.mysql.jdbc.Driver");Connection conn = null;Statement stat = null;ResultSet rs = null;try {conn = DriverManager.getConnection(url, username, password);stat = conn.createStatement();stat.executeQuery(sql);
}
Statement在調用查詢SQL方法時,調用executeQuery,導致出錯


3、解決辦法

     將“stat.executeQuery(sql);”換成“stat.execute(sql);”


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.