我有一个具有多个重复记录的表,如下所示:
ID Title
-----------------
1 Article A
2 Article A
3 Article B
4 Article C
5 Article A
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,我需要所有重复的标题,只留下一个.
B条和C条都没有问题.除了一个,我需要删除文章A.
样本输出:
ID Title
-----------------
1 Article A
3 Article B
4 Article C
Run Code Online (Sandbox Code Playgroud)
注意:我不关心要保留或删除哪个ID.我想要的只是一条记录.
假设我有大量具有重复标题的记录
有什么建议吗?
MySQL是否完全将WHERE条件中的方括号括起来?它像PHP一样工作吗
WHERE (condition1 OR condition2) AND condition3
Run Code Online (Sandbox Code Playgroud)
是相同的
if ((condition1 || condition2) && condition3)
Run Code Online (Sandbox Code Playgroud) 嗨有一个表名是cou
name type
kasu 1
kasu 4
kasu 3
nimal 1
nimal 2
Run Code Online (Sandbox Code Playgroud)
我需要这个答案
name cnt
kasu 3
Run Code Online (Sandbox Code Playgroud) 我正在尝试在服务器上传pdf文件.我在控制器中使用以下代码块:
@RequestMapping(value = /submit, method = RequestMethod.POST)
public String upload(UploadItem uploadItem, BindingResult result, HttpServletRequest request, HttpSession session) {
//some code here
String name = request.getServletContext().getRealPath("/pdf/" + filename);
File dest = new File(name);
try {
file.transferTo(dest);
}catch(Exception e){
System.err.println(e);
}
return "redirect:/details";
Run Code Online (Sandbox Code Playgroud)
我这样做是为了将pdf存储到pdf文件中.在我的localhost工作正常,但当我在服务器上执行此操作时,我采取以下异常:
exception
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getServletContext()Ljavax/servlet/ServletContext;
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getServletContext()Ljavax/servlet/ServletContext;
frontend.controller.EsteemRatingsController.handleFormUpload(EsteemRatingsController.java:113)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) …Run Code Online (Sandbox Code Playgroud) 我有小代码,如下所示
public class Testing {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String firstString = sc.next();
System.out.println("First String : " + firstString);
String secondString = "text\\";
System.out.println("Second String : " + secondString);
}
}
Run Code Online (Sandbox Code Playgroud)
当我以文本\\提供输入时,我得到输出为
First String : text\\
Second String : text\
Run Code Online (Sandbox Code Playgroud)
当我提供给第一个字符串的输入与第二个字符串相同时,为什么我得到两个不同的字符串.
我正在使用JSF2.0创建webapplication,在mysql中,我使用数据类型存储图像MEDIUMBLOB.
要插入值,我使用PreparedStatement,如下所示.
PreparedStatement psmnt = con.prepareStatement("INSERT INTO sketchesSG002003 (userid, imageTitle, imageData, drawingComments) VALUES (?,?,?,?)");
psmnt.setLong(1, personalInfoId);
psmnt.setString(2, sketchesSG002003Title);
try {
String fileName = FilenameUtils.getName(sketchesSG002003ImageUpload.getName());
File image = new File(fileName);
InputStream fis = sketchesSG002003ImageUpload.getInputStream();
psmnt.setBinaryStream(3, fis, (int) sketchesSG002003ImageUpload.getSize());
} catch (Exception e) {
psmnt.setBinaryStream(3, null);
}
psmnt.setString(4, sketchesSG002003Comments);
i = psmnt.executeUpdate();
Run Code Online (Sandbox Code Playgroud)
但是我收到了错误
java.lang.AbstractMethodError: com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;)V
Run Code Online (Sandbox Code Playgroud)
Stacktrace的某些部分是
javax.faces.el.EvaluationException: java.lang.AbstractMethodError: com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;)V
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
Run Code Online (Sandbox Code Playgroud)
我认为上面的错误是声明 psmnt.setBinaryStream(3, null);
我的问题是如何将二进制数据设置为Null或Nothing?
要在youtube应用上发布视频,我使用下面的代码.
NSURL *instagramURL = [NSURL URLWithString:@"youtube://foo"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
NSLog(@"opening youtube app...");
NSString *stringURL = @"http://www.youtube.com/watch?v=H9VdapQyWfg";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
} else {
// open in UIWebView in WebViewViewController
WebViewViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"webinterface"];
secondView.headerLabel = @"YouTube";
secondView.webPath = @"http://www.youtube.com/watch?v=H9VdapQyWfg";
[self.navigationController pushViewController:secondView animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
现在客户改变了主意,并要求在iPhone应用程序中放置频道.
为了测试,我使用了链接http://www.youtube.com/user/richarddawkinsdotnet
但是当我使用这个链接,而不是YouTube应用程序,它总是在Safari中打开.:(
关于如何在提供链接的YouTube应用中打开频道的任何想法/建议?
我有宽度为260的UILabel,我有很长的文本(可能大约1000个字符).
我想根据内容设置UILabel的高度.有时我可以有100个字符,有时候我可以有1000个字符.
根据文字,我如何设置UILabel的高度?
注意:我正在以编程方式创建UILabel.
UILabel myLabel = [[UILabel alloc] initWithFrame: CGRectMake (30,50,260, height)];
Run Code Online (Sandbox Code Playgroud)
知道怎么做到这一点?
我尝试的一种方法如下.
我在考虑一行有40个字符.所以我正在做的是找到文本的长度并将其除以40.这将给出我所需的总行数.
但是当有新线路时,这会失败.
这是对的吗?
我想要的是将webview的背景颜色设置为透明.
下面是我用于webview的代码.
NSString *embedHTML = [NSString stringWithFormat:@"<html><body style=\"background-color: transparent;font-family: verdana;\"><h3>About US</h3></BODY></HTML>"];
[webView loadHTMLString:embedHTML baseURL:nil];
Run Code Online (Sandbox Code Playgroud)
但是当我使用它时,我仍然将背景颜色视为白色.知道如何让颜色透明吗?
我正在使用JSF 2.0,我有文本字段作为
<h:form>
<h:inputText value="#{myBean.myValue}" />
<h:commandButton value="Submit" action="#{myBean.printMe()}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
public void printMe() {
System.out.println("first line==" + myValue + "==");
System.out.println("second line==????????????????==");
}
Run Code Online (Sandbox Code Playgroud)
当我运行这个项目并输入????????????????文本框时,在IDE控制台中我看到如下.
INFO: first line==????????????????==
INFO: second line==????????????????==
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?
mysql ×4
java ×3
ios ×2
objective-c ×2
backslash ×1
binarystream ×1
blob ×1
cgrectmake ×1
console ×1
count ×1
exception ×1
ios5 ×1
jsf ×1
operators ×1
php ×1
spring-mvc ×1
string ×1
transparency ×1
uilabel ×1
uiwebview ×1
utf-8 ×1
youtube ×1