GVKun编程网logo

java – Play2.0返回“SQLException:等待免费可用连接超时”.

9

如果您对java–Play2.0返回“SQLException:等待免费可用连接超时”.感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于java–Play2.0返回“SQLE

如果您对java – Play2.0返回“SQLException:等待免费可用连接超时”.感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于java – Play2.0返回“SQLException:等待免费可用连接超时”.的详细内容,并且为您提供关于Android java.net.SocketTimeoutException:连接超时、Android:造成原因:java.lang.RuntimeException:java.io.IOException:无效的常量类型:19 at 5、AWS RDS:java.sql.SQLException:用户、Java 9:java.lang.ClassNotFoundException:Spring Boot应用程序中的java.sql.SQLException的有价值信息。

本文目录一览:

java – Play2.0返回“SQLException:等待免费可用连接超时”.

java – Play2.0返回“SQLException:等待免费可用连接超时”.

我一直在使用Play 2.0.2来创建Java应用程序.几天我遇到了问题.在~100请求之后,服务器开始抛出此异常:

[[sqlException: Timed out waiting for a free available connection.]]

我用DB.getConnection()创建了一个新的Connection实例.我不关闭Connection实例,因为每个请求只有一个实例,据我所知,当活动TCP连接关闭时它会自动关闭Connection实例.
我试图将db.default.connectionTimeout值增加到100秒,但它无法解决问题.然后我检查了活动的Postgresql连接,并且没有活动连接.我也重新启动了Postgresql,但它也无法解决问题.

现在解决这个问题的唯一方法是杀死Play20实例并启动一个新实例.

这是Play2.0创建的日志:

! @6cg9il6ki - Internal server error,for request [GET [AN URL]] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[sqlException: Timed out waiting for a free available connection.]]
        at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.2]
        at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.2]
        at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
        at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.2]
        at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2]
        at akka.dispatch.MailBox.processMailBox(MailBox.scala:197) [akka-actor.jar:2.0.2]
Caused by: java.sql.sqlException: Timed out waiting for a free available connection.
        at com.jolBox.bonecp.BoneCP.getConnection(BoneCP.java:503) ~[bonecp.jar:0.7.1.RELEASE]
        at com.jolBox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:114) ~[bonecp.jar:0.7.1.RELEASE]
        at play.api.db.DBApi$class.getConnection(DB.scala:64) ~[play_2.9.1.jar:2.0.2]
        at play.api.db.BoneCPApi.getConnection(DB.scala:273) ~[play_2.9.1.jar:2.0.2]
        at play.api.db.DB$$anonfun$getConnection$1.apply(DB.scala:129) ~[play_2.9.1.jar:2.0.2]
        at play.api.db.DB$$anonfun$getConnection$1.apply(DB.scala:129) ~[play_2.9.1.jar:2.0.2]
最佳答案
你提到:

I don’t close the Connection instances because there’s only one
instance of each request

这是错的,你必须关闭它,否则你最终会遇到你看到的问题.

原因是您正在获得直接的JDBC连接,而不是由ORM管理的连接(EBeans或其他一些JPA兼容的),因此如果您不关闭它,连接可能会暂停一段时间.

Android java.net.SocketTimeoutException:连接超时

Android java.net.SocketTimeoutException:连接超时

最近,我在程序中遇到以下错误:

11-18 12:30:30.259: W/System.err(21368): java.net.socketTimeoutException: Connection timed out
11-18 12:30:30.259: W/System.err(21368):    at org.apache.harmony.luni.platform.OSNetworkSystem.connect(Native Method)
11-18 12:30:30.259: W/System.err(21368):    at dalvik.system.BlockGuard$WrappednetworkSystem.connect(BlockGuard.java:357)
11-18 12:30:30.259: W/System.err(21368):    at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:204)
11-18 12:30:30.259: W/System.err(21368):    at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
11-18 12:30:30.259: W/System.err(21368):    at java.net.socket.connect(Socket.java:1002)
11-18 12:30:30.259: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.httpconnection.<init>(httpconnection.java:75)
11-18 12:30:30.259: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.httpconnection.<init>(httpconnection.java:48)
11-18 12:30:30.269: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.httpconnection$Address.connect(httpconnection.java:322)
11-18 12:30:30.269: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.httpconnectionPool.get(httpconnectionPool.java:89)
11-18 12:30:30.269: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.gethttpconnection(HttpURLConnectionImpl.java:285)
11-18 12:30:30.269: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
11-18 12:30:30.269: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)
11-18 12:30:30.269: W/System.err(21368):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getoutputStream(HttpURLConnectionImpl.java:614)
11-18 12:30:30.269: W/System.err(21368):    at com.example.simplevider.SimpleVideo$4.run(SimpleVideo.java:122)
11-18 12:30:30.279: W/System.err(21368):    at java.lang.Thread.run(Thread.java:1019)

产生此错误的函数如下:

    private void sendStuff() {
    Log.e("sendStuff", "======================================");
    new Thread(new Runnable() {

        @Override
        public void run() {
            final int BUFFER_SIZE = 4096;
            try {
                File uploadFile = new File(existingFileName);
                System.out.println("File to upload: " + existingFileName);
                URL url = new URL(URL);

                HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
                httpConn.setUseCaches(false);
                httpConn.setDoOutput(true);
                httpConn.setRequestMethod("POST");
                httpConn.setReadTimeout(60*1000);
                httpConn.setConnectTimeout(60 * 1000);
                // sets file name as a HTTP header
                httpConn.setRequestProperty("fileName", uploadFile.getName());
                httpConn.setRequestProperty("extra-id", uploadFile.getAbsoluteFile().toString());
                httpConn.setRequestProperty("extra-id2", uploadFile.getParent());
                httpConn.setRequestProperty("extra-id3", uploadFile.length() + "");



                OutputStream outputStream = httpConn.getoutputStream(); //<< this is the source of the error


                FileInputStream inputStream = new FileInputStream(uploadFile);

                byte[] buffer = new byte[BUFFER_SIZE];
                int bytesRead = -1;

                System.out.println("Start writing data...");

                while ((bytesRead = inputStream.read(buffer)) != -1) {
                    outputStream.write(buffer, 0, bytesRead);
                }

                System.out.println("Data was written.");
                outputStream.close();
                inputStream.close();

                // always check HTTP response code from server
                int responseCode = httpConn.getResponseCode();
                if (responseCode == HttpURLConnection.HTTP_OK) {
                    // reads server's response
                    BufferedReader reader = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
                    String response = reader.readLine();
                    System.out.println("Server's response: " + response);
                } else {
                    System.out.println("Server returned non-OK code: " + responseCode);
                }

            } catch (Exception e) {
                e.printstacktrace();
                sendStuff();
            }

        }
    }).start();

}

此函数在正常的JAVA中可以正常使用,但是当复制到Android时,它会抛出java.net.socketTimeoutException:连接超时,我不知道为什么.

解决方法:

有两种可能性,

1)您是否检查并测试了连接.

2)最好不要设置任何连接超时,如果您设置了选择的最大时间,则bcos会引发错误,如果服务器在给定时间内没有响应.

Android:造成原因:java.lang.RuntimeException:java.io.IOException:无效的常量类型:19 at 5

Android:造成原因:java.lang.RuntimeException:java.io.IOException:无效的常量类型:19 at 5

如何解决Android:造成原因:java.lang.RuntimeException:java.io.IOException:无效的常量类型:19 at 5?

我们正在将Hotfix Robust lib集成到我的应用程序中。在运行该应用程序时,我们遇到以下错误。我们已经将compileOptions设置为 Java8 版本,并且还尝试通过添加 Javaassist 版本 3.27.0-GA ,但没有运气。

Execution Failed for task '':compex_task_runner:transformClassesWithRobustForProdRelease''

[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.io.IOException: invalid constant type: 19 at 5

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

AWS RDS:java.sql.SQLException:用户

AWS RDS:java.sql.SQLException:用户

AmazonRDSDataFullAccess策略用于与无服务器RDS数据API进行交互。它不提供执行IAM身份验证的标准数据库连接所需的适当权限。您需要遵循指南here来创建适当的策略。特别是,您需要授予EC2实例配置文件rds-db:connect权限。

,

您可以尝试以下操作:

  1. 尝试重新创建数据库用户并再次授予它权限
  2. 代替内联策略,尝试使用客户托管策略,直到解决连接问题
  3. 内联策略中的资源ARN后面有一个逗号,也应将其删除。
,

我将策略附加到EMR角色,我不得不将其附加到EMR集群的EC2实例配置文件中

Java 9:java.lang.ClassNotFoundException:Spring Boot应用程序中的java.sql.SQLException

Java 9:java.lang.ClassNotFoundException:Spring Boot应用程序中的java.sql.SQLException

这个应用程式怎么了?我认为类路径jar和模块jar的混合是有效的。对于所有没有显式module-info的jar都是自动模块?当我删除module-
info.java时,它可以工作。因为在这种情况下,IDEA使用类路径。

Java(TM)SE运行时环境(内部版本9 + 176)

IntelliJ IDEA 2017.1.4版

module-info.java

module test {
    requires spring.boot.autoconfigure;
    requires spring.boot;
}

App.java

package com.foo.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App {

    public static void main(String[] args) {
        SpringApplication.run(App.class,args);
    }
}

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.foo.test</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M2</version>
    </parent>

    <name>test</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.9</maven.compiler.source>
        <maven.compiler.target>1.9</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>

线程“主”中的异常java.lang.IllegalArgumentException:无法实例化接口org.springframework.context.ApplicationContextInitializer:org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer位于spring.boot@2.0.0.M2/org.springframework.boot.SpringApplication在spring.boot@2.0.0.M2/org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)在spring.boot@2.0.0.M2/org.springframework的.createSpringFactoriesInstances(SpringApplication.java:439)在spring.boot@2.0.0.M2/处的.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:409)/在spring.boot@2.0.0.M2/处的org.springframework.boot.SpringApplication。(SpringApplication.java:266)
org.springframework.boot.SpringApplication。(SpringApplication.java:247)在spring.boot@2.0.0.M2/org.springframework.boot.SpringApplication.run(SpringApplication.java:1245)在spring.boot@2.0.0.M2/org.springframework.boot.SpringApplication.run(在test
/ com.foo.test.App.main(App.java:10)处的SpringApplication.java:1233)由以下原因引起:
java.lang.NoClassDefFoundError:
在spring.beans@5.0.0.RC2/org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:145)上的
java / sql / SQLException
在spring.boot@2.0.0.M2/org上.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:435)…还有7个原因:java.lang.ClassNotFoundException:java.base
/
jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader)上的java.sql.SQLException
.java:582),位于java.base / jdk.internal.loader.ClassLoaders $
AppClassLoader.loadClass(ClassLoaders.java:185),位于java.base /
java.lang.ClassLoader.loadClass(ClassLoader.java:496)…另外9个

关于java – Play2.0返回“SQLException:等待免费可用连接超时”.的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Android java.net.SocketTimeoutException:连接超时、Android:造成原因:java.lang.RuntimeException:java.io.IOException:无效的常量类型:19 at 5、AWS RDS:java.sql.SQLException:用户、Java 9:java.lang.ClassNotFoundException:Spring Boot应用程序中的java.sql.SQLException的相关信息,请在本站寻找。

本文标签: