Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

DB2 in spring,DisconnectException

$
0
0
hi guys,I'm trying to connect to DB2 with spring framework,and I got an Exception:com.ibm.db2.jcc.b.DisconnectException: The application server rejected establishment of the connection. An attempt was made to access a database, TSTDB202, which was not found,this exception says the database doesn't exist ,but actually it does,because when I use a java application just like the code below,I succeed in connecting to DB2,so it means the url is correct.
Code:

public class test2 {
        private String url = "jdbc:db2://202.115.7.251:448/TSTDB202";
        private String driver = "com.ibm.db2.jcc.DB2Driver";
        private String user = "****";
        private String password = "****";

        public DB2Connection getCon() {
                DB2Connection con = null;
                try {
                        Class.forName(driver);

                        con = (DB2Connection) DriverManager.getConnection(url, user,
                                        password);
        .....
        .....

The url,username,and password are the same with the properties I set in applicationContext.xml
Code:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <!-- JDBCDriver -->
                <property name="driverClass">
                        <value>com.ibm.db2.jcc.DB2Driver</value>
                </property>
                <!-- URL -->
                <property name="jdbcUrl">
                        <value>jdbc:db2://202.115.7.251:448/TSTDB202
                        </value>
                </property>
                <!-- username -->
                <property name="user">
                        <value>****</value>
                </property>
                <!-- password -->
                <property name="password">
                        <value>****</value>
                </property>
                <property name="maxPoolSize">
                        <value>30</value>
                </property>
                <property name="minPoolSize">
                        <value>1</value>
                </property>
                <property name="initialPoolSize">
                        <value>1</value>
                </property>
                <property name="maxIdleTime">
                        <value>20</value>
                </property>
        </bean>

The required jars,db2jcc_license_cu and db2jcc are also included,I can't locate the reason.
Please give me help,thanks in advance:)

Viewing all articles
Browse latest Browse all 297

Trending Articles