gpt4 book ai didi

java - 无法在 SQL Server 2008 R2 上执行(删除)查询

转载 作者:行者123 更新时间:2023-12-01 04:34:43 26 4
gpt4 key购买 nike

我想删除数据库中包含 .jpg 扩展名的 URL 的所有行!

我正在使用

 try{
java.sql.Statement mystat=connection.createStatement();
String delete_jpg="DELETE FROM mytable WHERE mycol LIKE '%.jpg%' ";
mystat.executeUpdate(delete_jpg);
}catch(Exception e){
}

使用 Java JDBC 执行此查询根本不会出现任何错误,但它也不会删除行!请有人告诉我我做错了什么!!!

示例 URL 为:

 images/affiliation-logo4.png HTTP/1.1
images/661.jpg HTTP/1.1
footerslider/images/blue-left-arrow.png HTTP/1.1
footerslider/images/blue-right-arrow.png HTTP/1.1
media/contentHeader/32.jpg HTTP/1.1 //I want to delete this type of rows
index.php?option=com_content&task=view&id=543 HTTP/1.1
images/favic.ico HTTP/1.1
src/ HTTP/1.0
uiit/faculty.php?dept_id=31 HTTP/1.1
uims/faculty.php?dept_id=32 HTTP/1.1
media/profile/dhS1t8X.jpg HTTP/1.1 //I want to delete this type of rows
media/profile/SSbkpgG.jpg HTTP/1.1 //I want to delete this type of rows

最佳答案

从您的示例 URL 中我看到该模式是:

 media/profile/dhS1t8X.jpg HTTP/1.1     //I want to delete this type of rows

问题是你做得正确,但模式应该是这样的:

try{
java.sql.Statement mystat=connection.createStatement();
String delete_jpg="DELETE FROM mytable WHERE mycol LIKE '%.jpg %' "; //HERE YOU HAVE TO ADD A WHITE SPACE AFTER THE .jpg as you can also seen in your sample URL!
mystat.executeUpdate(delete_jpg);
}catch(Exception e){
}

去做吧,一定会对你有帮助!

关于java - 无法在 SQL Server 2008 R2 上执行(删除)查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17491454/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com