Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Not able connect IBM DB2 with Java 1.8 installed on client system and Java 1.6 installed on server system

I want connect IBM DB2 with Java Code Client System having Java 1.8 and Server System Having 1.6 Java and I am using db2jcc4.jar to load driver

below is my code snippet

public class ConnectionExample {

public static void main(String[] args) {
    String jdbcClassName="com.ibm.db2.jcc.DB2Driver";
    String url="jdbc:db2://XXX.XXX.XXX.XX:1443/exampledb";
    String user="username";
    String password="password";

    Connection connection = null;
    try {
        //Load class into memory
        Class.forName(jdbcClassName);
        //Establish connection
        connection = DriverManager.getConnection(url, user, password);

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (SQLException e) {
        e.printStackTrace();
    }finally{
        if(connection!=null){
            System.out.println("Connected successfully.");
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}

}

is some help me for this connection as i am getting error while connecting DB how to check is port number is occupied by DB is correct ?

Comments