问题列表 - 第207104页

SQL datetime比较

我想从我的表中获取一些值,其中有一些关于其datetime列的条件.

我想从我的表中获取所述城市的所有酒店值,该表名为"LocalHotels".我还应该声明两个DateTime值.第一个值应小于或等于"开始"列中酒店的值,即datetime数据类型.第二个值应该大于或等于"截止日期"列中酒店的值,也就是datetime数据类型.

datetime这两列中的所有值都以德语CultureInfo格式插入.

当我在下面陈述查询时,没有问题;

string query = "SELECT * FROM LocalHotels WHERE city='LONDON' AND start <='5.12.2015 00:00:00' AND deadline >='8.12.2015 00:00:00' ORDER BY city";
Run Code Online (Sandbox Code Playgroud)

但是,当我将值的一天DateTime值从一位数改为两位数时,如下所述;

string query "SELECT * FROM LocalHotels WHERE city='LONDON' AND start <='15.12.2015 00:00:00' AND deadline >='18.12.2015 00:00:00' ORDER BY city"
Run Code Online (Sandbox Code Playgroud)

我有一个SQLException表示;

将varchar数据类型转换为日期时间数据类型会导致超出范围的值.

sql-server datetime

6
推荐指数
3
解决办法
6万
查看次数

按Java 8中的Map列表分组

我有一个像这样的列表:

List<Map<String, Long>>
Run Code Online (Sandbox Code Playgroud)

有没有办法,使用lambda,将此列表转换为:

Map<String, List<Long>>
Run Code Online (Sandbox Code Playgroud)

例:

Map<String, Long> m1 = new HashMap<>();
m1.put("A", 1);
m1.put("B", 100);

Map<String, Long> m2 = new HashMap<>();
m2.put("A", 10);
m2.put("B", 20);
m2.put("C", 100);

List<Map<String, Long>> beforeFormatting = new ArrayList<>();
beforeFormatting.add(m1);
beforeFormatting.add(m2);
Run Code Online (Sandbox Code Playgroud)

格式化后:

Map<String, List<Long>> afterFormatting;
Run Code Online (Sandbox Code Playgroud)

看起来像是这样的:

A -> [1, 10]
B -> [100, 20]
C -> [100]
Run Code Online (Sandbox Code Playgroud)

java lambda java-8 java-stream

13
推荐指数
1
解决办法
5754
查看次数

Python字符串文字串联

我可以使用以下语法创建多行字符串:

string = str("Some chars "
         "Some more chars")
Run Code Online (Sandbox Code Playgroud)

这将产生以下字符串:

"Some chars Some more chars"
Run Code Online (Sandbox Code Playgroud)

Python是加入这两个单独的字符串还是编辑器/编译器将它们视为单个字符串?

Ps:我只想了解内部情况.我知道还有其他方法来声明或创建多行字符串.

python string python-2.7 python-internals

6
推荐指数
1
解决办法
4137
查看次数

doctrine ORM count arraycollection in where condition

使用Symfony2.8with Doctrine 2.5,我想在Doctrine ORM查询中过滤所有数据集,其中arraycollection恰好包含3个元素.

$em = $this->getDoctrine()->getManager();
$query = $em->getRepository("AppBundle:EduStructItem")
->createQueryBuilder('e')
 ->addSelect('COUNT(e.preconditions) AS HIDDEN numberpre')
 ->having('numberpre = 3')
->getQuery();
$res = $query->getResult();
dump($res);
foreach ($res as $entity){
    print "title:".$entity->getTitle()."<br>";
    dump($entity->getPreconditions()->toArray());
}
Run Code Online (Sandbox Code Playgroud)

preconditions 是一个包含前提条件集合的arraycollection.

最后,我希望得到所有结果正好有3个前提条件.另外,也可以通过arraycollection中的值的数量来排序(类似order by Count(e.preconditions)).

由于使用了另一个捆绑包,我将原则从2.5.2降级到2.5.0.我不认为这是我的问题的原因,但为了完整起见,这是我的作曲家秀的教义部分:

data-dog/pager-bundle                v0.2.4             Paginator bundle for symfony2 and doctrine orm, allows customization with filters and sorters
  doctrine/annotations                 v1.2.7             Docblock Annotations Parser
  doctrine/cache                       v1.5.2             Caching library offering an object-oriented API for many cache backends
  doctrine/collections                 v1.3.0             Collections Abstraction library
  doctrine/common …
Run Code Online (Sandbox Code Playgroud)

orm arraycollection symfony doctrine-orm

6
推荐指数
1
解决办法
2264
查看次数

SPARQL的正则表达式

我从dbpedia下载了dbpedia_quotationsbook.zip,其中包含dbpedia_quotationsbook.nt triplestore.

在这个三元店

subject是authorname
谓词是"sameas"
对象是authorcode

我使用JENA尝试了这个查询三元组,简单的查询正在运行.

现在我想要所有的authorcode,其authorname与给定的字符串部分匹配.所以我尝试了以下查询

select ?code
where
{

FILTER regex(?name, "^Rob")  <http://www.w3.org/2002/07/owl#sameAs> ?code.

}
Run Code Online (Sandbox Code Playgroud)

上面的查询应返回其authorname包含"Rob"的所有authorcodes

我得到以下异常

Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Encountered " "." ". "" at line 5, column 74.
Was expecting one of:
    <IRIref> ...
    <PNAME_NS> ...
    <PNAME_LN> ...
    <BLANK_NODE_LABEL> ...
    <VAR1> ...
    <VAR2> ...
    "true" ...
    "false" ...
    <INTEGER> ...
    <DECIMAL> ...
    <DOUBLE> ...
    <INTEGER_POSITIVE> ...
    <DECIMAL_POSITIVE> ...
    <DOUBLE_POSITIVE> ...
    <INTEGER_NEGATIVE> ...
    <DECIMAL_NEGATIVE> ...
    <DOUBLE_NEGATIVE> ...
    <STRING_LITERAL1> ...
    <STRING_LITERAL2> …
Run Code Online (Sandbox Code Playgroud)

java rdf sparql apache-jena

1
推荐指数
1
解决办法
977
查看次数

“multipart/form-data”POST 请求实际上是否应该包含带有上传图像数据的字符串?

我正在为一个 Web 应用程序创建一些性能测试,该应用程序发送的请求类型与浏览器发送到我们的服务器的类型相同。其中一个请求是上传图像的 POST。我查看了这个问题,看起来图像文件的实际内容应该位于请求正文内。然而,当我在 Chrome 中使用 F12 开发工具来检查浏览器在请求中发送的内容时,它看起来像这样:

  ------WebKitFormBoundaryjHN86sGb89n2HUZOT
  Content-Disposition: form-data; name="profileImg[]"; filename="bmp.bmp"
  Content-Type: image/bmp


  ------WebKitFormBoundaryjHN86sGb89n2HUZOT--
Run Code Online (Sandbox Code Playgroud)

我期望看到文件内容的空间是空白的。我期待看到一些看似随机的字符串,代表图像文件的内容。请求中也没有图像的路径,只有文件名,所以我无法准确理解如何上传文件?Chrome 是否只是向我隐藏了数据?

post http google-chrome-devtools

3
推荐指数
1
解决办法
5204
查看次数

在php中解码json就像字符串一样

我有一个存储在MySQL数据库(joomla)中的字符串,从下面开始.有谁知道这是什么类型的字符串以及如何将其解码为PHP中的数组?它看起来类似于JSON,但我不确定.

a:4:{s:7:"Enabled";s:3:"yes";s:9:"StoreData";a:3:{i:1;a:9:{s:2:"id";s:1:"1";s:7:"Enabled";s:3:"yes";s:4:"Name";a:1:{i:1;s:13:
Run Code Online (Sandbox Code Playgroud)

php json

2
推荐指数
1
解决办法
65
查看次数

尝试在后台线程中加载/设置场景导致"OpenGL错误0x0502 in - [CCSprite draw] 530"

我有一个cocos2d v2.x应用程序,它有一个场景,有很多精灵,节点,配置,数据等......加载非常昂贵,以至于当将场景添加到导演时,有一个暂停1/2到1秒,导致当前运行的动画冻结,直到加载场景.我描述了最慢的方法,并尝试在后台线程中异步执行它们,并在加载时显示进度微调器.

我的实现是这样的:

-(void)performAsyncLoad {
    self.progressSpinner.visible = YES;
    self.containerForLoadedStuff.visible = NO;
    self.mainContext = [EAGLContext currentContext];

    NSOperationQueue *queue = [NSOperationQueue new];
    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                            selector:@selector(loadDependencies)
                                                                              object:nil];
    [queue addOperation:operation];
}

-(void)loadDependencies {
    @autoreleasepool {
        glFlush();
        EAGLSharegroup *shareGroup = [[(CCGLView*)[[CCDirector sharedDirector] view] context] sharegroup];
        EAGLContext *context = [[EAGLContext alloc] initWithAPI:[[EAGLContext currentContext] API] sharegroup:shareGroup];
        [EAGLContext setCurrentContext:context];

        // ... expensive stuff here
        // [self.containerForLoadedStuff addChild:sprites, etc...]

        [self performSelectorOnMainThread:@selector(done) withObject:nil waitUntilDone:NO];
    }
}

-(void)done {
    glFlush();
    [EAGLContext setCurrentContext:self.mainContext];
    self.progressSpinner.visible = NO;
    self.containerForLoadedStuff.visible = …
Run Code Online (Sandbox Code Playgroud)

opengl-es cocos2d-iphone

5
推荐指数
1
解决办法
238
查看次数

java字符串操作,将多个斜杠更改为一个斜杠

愚蠢的错误+用来代替+

所有,我试图将输入路径中的所有"/ +"转换为"/"以简化unix风格的路径.

 path.replaceAll( "/+", "/"); 
 path.replaceAll( "\\/+", "/"); 
Run Code Online (Sandbox Code Playgroud)

事实证明没有做任何事情,这样做的正确方法是什么?

public class SimplifyPath {
public String simplifyPath(String path) {
    Stack<String> direc = new Stack<String> ();
    path = path.replaceAll("/?", "/");
    System.out.println("now path becomes " + path);  // here path remains "///"

    int i = 0;
    while (i < path.length() - 1) {
        int slash = path.indexOf("/", i + 1);
        if (slash == -1) break;
        String tmp = path.substring(i, slash);
        if (tmp.equals("/.")){
            continue;
        } else if (tmp.equals("/..")) {
            if (! direc.empty()){
                direc.pop(); …
Run Code Online (Sandbox Code Playgroud)

java string replaceall

1
推荐指数
1
解决办法
1225
查看次数

无法使用相同的密钥发送带有参数的改装2.0多部分请求

我需要使用具有图像改造2.0和一些键值参数发送multipart请求:"key1" - "parameter1","key2" - "parameter2"等,但也有使用相同的密钥参数: "somepar[]" - "text1","somepar[]" - "text2"...我不能使用@PartMap这个结构:

@Multipart
@POST(myUrlPart)
Call<ClassEntity> myRequest(@Header("Authorization") String authHeader,
                                @Part("image\"; filename=\"image.png\"") RequestBody image,
                                @PartMap Map<String, RequestBody> params); 
Run Code Online (Sandbox Code Playgroud)

因为Map <>无法使用相同的键存储多个值.而我无法使用

@Part("somepar[]") List<String> mylist  
Run Code Online (Sandbox Code Playgroud)

要么

@Part("somepar[]") String[] myArray  
Run Code Online (Sandbox Code Playgroud)

因为它会发送键值"somepar[]" - "{"1","2","3"}",不"somepar[]" = "1" , "somepar[]" = "2" ,"somepar[]" = "3".

请帮忙,如何提出这样的要求.

android retrofit

7
推荐指数
1
解决办法
716
查看次数