代码之家  ›  专栏  ›  技术社区  ›  Muizz Mahdy

使用远程数据库作为spring boot数据源

  •  0
  • Muizz Mahdy  · 技术社区  · 5 年前

    IBM DB2 数据库。我在我的 application.properties 文件:

    spring.jpa.hibernate.ddl-auto=none
    spring.datasource.url=jdbc:db2://<dbhost>:<dbport>/<db>
    spring.datasource.username=<username>
    spring.datasource.password=<password>
    

    spring:
      datasource:
        url: jdbc:db2://dashdb-txn-sbox.services.eu-gb.bluemix.net:3000/BLUDB:sslConnection=true;
      username: <username>
      password: <password>
      driverClassName: com.ibm.db2.jcc.DB2Driver
     jpa:
       properties:
         hibernate:
           dialect: org.hibernate.dialect.DB2Dialect
    

    不过,我还是有这个错误:

    A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream. Error location: Reply.fill() - socketInputStream.read (-1). Message: Read timed out. ERRORCODE=-4499, SQLSTATE=08001
    
    0 回复  |  直到 5 年前
        1
  •  1
  •   mao    5 年前

    这个问题更多的是关于配置而不是编程。

    FAQ for JDBC ERRORCODE -4499

    其中提到:

    (A.5)消息:读取超时

    当客户端正在等待来自 超时。确保JDBC驱动程序属性中没有设置超时:

    blockingReadConnectionTimeout=0 (default)
    commandTimeout=0 (default)
    loginTimeout = 0 (default)
    

    如果问题持续存在,请确保使用 JDBCDB2驱动程序(目前是4.26.14或更高版本)。

    您可以使用jdbc trace(按照IBM Db2文档中的说明来启用jdbc trace)在封面下查看到底发生了什么。

        2
  •  0
  •   Paul Vernon    5 年前

    50001是ssl连接的常用(默认)端口号,而不是问题中的3000