Error No Buffer Space Available when Using Java, MyBatis and MySql

I’ve met a very weird error, that are not supposed to happen, when using MyBatis and MySql. Somehow my Windows OS is running out of ports, this is the complete stacktrace.

Caused by: No buffer space available (maximum connections reached?): connect
    at Method)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at<init>(Unknown Source)
    at<init>(Unknown Source)
    at com.mysql.jdbc.StandardSocketFactory.connect(
    at com.mysql.jdbc.MysqlIO.<init>(]

I found out it happened because im using traditional unpooled connection, changing it into pooled connection in MyBatis solved it.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-// Config 3.0//EN"
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://localhost/xxxx"/>
                <property name="username" value="xxxx"/>
                <property name="password" value=""/>
                <property name="poolMaximumActiveConnections" value="20"/>


No Comments

Leave a Comment

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked

:-[ (B) (^) (P) (@) (O) (D) :-S ;-( (C) (&) :-$ (E) (~) (K) (I) (L) (8) :-O (T) (G) (F) :-( (H) :-) (*) :-D (N) (Y) :-P (U) (W) ;-)