Search code examples
javamysqlspringc3p0

How to use mysql custom port in c3p0 datasource?


I have a mysql running on 3306 port in my local system. and also there is another mysql is running on 13000. while im trying to connect to 13000 instance still it is connecting to 3306 instance. c3p0 datasource is taking the default port and it is simply ignoring the port. so could some one help on this???

Spring bean:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">

        <property name="driverClass" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUrl" value="jdbc:mysql://localhost:13000/dbname?autoReconnect=true" />
        <property name="user" value="user" />
        <property name="password" value="pwd" />

        <property name="idleConnectionTestPeriod" value="55" />
        <property name="initialPoolSize" value="10" />
        <property name="maxIdleTime" value="60" />

        <property name="maxPoolSize" value="15" />
        <property name="minPoolSize" value="5" />
    </bean> 

Edit: Even simple JDBC program is connecting to 3306.


Solution

  • Finally found the issue. The reason is i am using mysql-connector-java.5.1.9.jar, so there is a bug in that connector. So i changed it to latest version then my issue got resolved.

    Thanks.