小编Mat*_*nit的帖子

为什么Java的SSLSocket发送版本2客户端问候?

SSLSocket.getEnabledProtocols()方法返回以下内容: [SSLv2Hello, SSLv3, TLSv1].事实上,当我打电话connect()并打开SSL调试时,我看到使用了一个v2客户端问候:

main, WRITE: TLSv1 Handshake, length = 81
main, WRITE: SSLv2 client hello message, length = 110
Run Code Online (Sandbox Code Playgroud)

但我已经发现了两个(诚然旧)基准说JSSE并不能支持SSL版本2:

来自Java的基础网络:

'SSLv2Hello'是一种伪协议,它允许Java使用SSLv2'hello消息'发起握手.这并不会导致使用的SSLv2协议,这是不是Java的所有支持.

并从JSSE参考指南:

J2SDK 1.4及更高版本中的JSSE实现实现了SSL 3.0和TLS 1.0.它没有实现SSL 2.0.

现在,我的理解是,当客户端2.0版客户端问候应只发送支持SSL 2.0版.来自RFC 2246:

支持SSL 2.0版服务器的TLS 1.0客户端必须发送SSL 2.0版客户端问候消息[SSL2] ... 警告:发送2.0版客户端问候语消息的能力将逐步淘汰.

那么为什么Java使用它呢?

java ssl jsse

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

为什么PostgreSQL数组在C中的访问速度比在PL/pgSQL中快得多?

我有一个表模式,其中包含一个int数组列,以及一个自定义聚合函数,它对数组内容求和.换句话说,给出以下内容:

CREATE TABLE foo (stuff INT[]);

INSERT INTO foo VALUES ({ 1, 2, 3 });
INSERT INTO foo VALUES ({ 4, 5, 6 });
Run Code Online (Sandbox Code Playgroud)

我需要一个可以返回的"sum"函数{ 5, 7, 9 }.正确运行的PL/pgSQL版本如下:

CREATE OR REPLACE FUNCTION array_add(array1 int[], array2 int[]) RETURNS int[] AS $$
DECLARE
    result int[] := ARRAY[]::integer[];
    l int;
BEGIN
  ---
  --- First check if either input is NULL, and return the other if it is
  ---
  IF array1 IS NULL OR array1 = '{}' THEN
    RETURN array2;
  ELSEIF …
Run Code Online (Sandbox Code Playgroud)

c arrays postgresql plpgsql aggregate-functions

19
推荐指数
2
解决办法
3616
查看次数

处理ON DELETE CASCADE约束的顺序是什么?

这是我发生的事情的一个例子:

CREATE TABLE Parent (id BIGINT NOT NULL,
  PRIMARY KEY (id)) ENGINE=InnoDB;

CREATE TABLE Child (id BIGINT NOT NULL,
  parentid BIGINT NOT NULL,
  PRIMARY KEY (id),
  KEY (parentid),
  CONSTRAINT fk_parent FOREIGN KEY (parentid) REFERENCES Parent (id) ON DELETE CASCADE) ENGINE=InnoDB;

CREATE TABLE Uncle (id BIGINT NOT NULL,
  parentid BIGINT NOT NULL,
  childid BIGINT NOT NULL,
  PRIMARY KEY (id),
  KEY (parentid),
  KEY (childid),
  CONSTRAINT fk_parent_u FOREIGN KEY (parentid) REFERENCES Parent (id) ON DELETE CASCADE,
  CONSTRAINT fk_child FOREIGN KEY (childid) REFERENCES Child …
Run Code Online (Sandbox Code Playgroud)

mysql database-design mysql-error-1451

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

使用嵌入式Jetty 7发布JAX-WS端点

任何人都可以帮忙吗?

我想使用嵌入式Jetty 7作为端点.这是我试过的:

public class MiniTestJetty {

@WebService(targetNamespace = "http")
public static class Calculator {

    @Resource
    WebServiceContext context;

    public int add(int a, int b) {
        return a + b;
    }
}


public static void main(String[] args) throws Exception {
    int port = 8080;
    Server server = new Server(port);

    Calculator calculator = new Calculator();
    Endpoint.publish("http://localhost:" + port + "/calc", calculator);

    server.start();
    server.join();
}
Run Code Online (Sandbox Code Playgroud)

}

但我无法确定这是否真的使用Jetty而不是默认的sun HttpServer.

一篇博客提到

 System.setProperty("com.sun.net.httpserver.HttpServerProvider",
       "org.mortbay.jetty.j2se6.JettyHttpServerProvider");
Run Code Online (Sandbox Code Playgroud)

但是在Jetty 7中似乎没有这样的HttpServerProvider.

感谢任何帮助,Axel.

java jax-ws embedded-jetty

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

如何使用JPA或HQL动态订购多对多关系?

我有这样的映射:

@ManyToMany(cascade = CascadeType.PERSIST)
    @JoinTable(
            name="product_product_catalog",
            joinColumns={@JoinColumn(name="product_catalog", referencedColumnName="product_catalog")},
            inverseJoinColumns={@JoinColumn(name="product", referencedColumnName="product")})
    public List<Product> products = new ArrayList<Product>();
Run Code Online (Sandbox Code Playgroud)

我可以很好地获取目录的产品,但我不能(动态)订购产品.我怎么能订购它们?我可能不得不用order-by子句写一个多对多的HQL查询?我虽然将orderBy字段名称字符串传递给查询,还是有更好的解决方案?

表是:products,product_catalog,product_product_catalog(associative table)

PS使用播放!我的实体的框架JPASupport.

java many-to-many jpa hql sql-order-by

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

使用JAXB解组列表

我知道这是一个初学者的问题,但是我现在一直在撞墙挡了两个小时,试图解决这个问题.

我从REST服务(Windows Azure Management API)返回XML,如下所示:

<HostedServices
  xmlns="http://schemas.microsoft.com/windowsazure"
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <HostedService>
    <Url>https://management.core.windows.net/XXXXX</Url>
    <ServiceName>foo</ServiceName>
  </HostedService>
  <HostedService>
    <Url>https://management.core.windows.net/XXXXX</Url>
    <ServiceName>bar</ServiceName>
  </HostedService>
</HostedServices>
Run Code Online (Sandbox Code Playgroud)

当我尝试使用JAXB解组它时,服务列表始终为空.

我想尽可能避免编写XSD(微软不提供).这是JAXB代码:

  JAXBContext context = JAXBContext.newInstance(HostedServices.class, HostedService.class);
  Unmarshaller unmarshaller = context.createUnmarshaller();
  HostedServices hostedServices = (HostedServices)unmarshaller.unmarshal(new StringReader(responseXML));

  // This is always 0:
  System.out.println(hostedServices.getHostedServices().size());
Run Code Online (Sandbox Code Playgroud)

以下是Java类:

@XmlRootElement(name="HostedServices", namespace="http://schemas.microsoft.com/windowsazure")
public class HostedServices
{
  private List<HostedService> m_hostedServices = new ArrayList<HostedService>();

  @XmlElement(name="HostedService")
  public List<HostedService> getHostedServices()
  {
    return m_hostedServices;
  }

  public void setHostedServices(List<HostedService> services)
  {
    m_hostedServices = services;
  }
}

@XmlType
public class HostedService
{
  private String m_url;
  private String …
Run Code Online (Sandbox Code Playgroud)

java list jaxb azure

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

我可以关闭由我不拥有的代码打开的文件句柄吗?

我正在使用第三方商业库,这似乎是泄漏文件句柄(我在Linux上验证了这一点lsof).最终服务器(Tomcat)开始得到臭名昭着的"太多打开文件错误",我必须重新启动JVM.

我已经联系了供应商.然而,与此同时,我想找到一个解决方法.我无权访问他们的源代码.有什么办法,在Java中,清理文件句柄,而不具有原始访问File对象(或者FileWriter,FileOutputStream等)?

java io

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

编写方法签名,包括文档的类名

是否有语言标准(或通用实践)来描述包含类名的Objective-C方法?

例如,假设我有以下伪代码:

class Foo
{
  void bar(int i);
}
Run Code Online (Sandbox Code Playgroud)

我想为它写一些文档.

如果这是Java,我会将该方法称为Foo.bar().如果它是C++,我会用Foo::bar.为Objective-C做这个的正确方法是什么?

我知道我可以使用-(void) bar:(int)i,但这不包括类(或协议)名称.

documentation objective-c

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