0

I have created JDBC connection to my schema "DASH104582" and i am using java 7th version and i have download jar file in google and pasted under external_lib folder. This is my connection code

DriverManager.getConnection("jdbc:db2://yp-dashdb-small-01-lon02.services.eu-gb.bluemix.net:50001/BLUDB:sslConnection=true");.

I am tried to select the data from the dashdb.

If I run the program its showing error

java.sql.SQLException: No suitable driver found for jdbc:db2://yp-dashdb-small-01-lon02.services.eu-gb.bluemix.net:50001/BLUDB:sslConnection=true

Please solve my issues and due you have any sample code give me..,

1 Answers1

1

The URL format you provided implies JDBC type 4 connection type. For this, make sure you are using db2jcc4.jar driver JAR, and not db2jcc.jar driver JAR.

Include full path to the db2jcc4.jar JAR in the CLASSPATH in the environment in which you invoke your program. Do not include db2jcc.jar in the CLASSPATH.

You mention placing the jar under "extension_lib". I suspect you mean ext/lib directory under your JRE installation. Although that will work in principle, unless you have some very specific reason for treating this driver JAR as a JRE installed extension, you should instead simply add the path to the driver JAR to the CLASSPATH.

If you are running your application in UNIX/Linux environment, make sure that read access to the driver JAR file is enabled for the user under which your application is running (e.g. chmod a+r ./db2jcc4.jar).

As a quick check that the driver class is successfully resolved at runtime, you can temporarily add this line before the DriverManager.getConnection() line:

Class.forName("com.ibm.db2.jcc.DB2Driver");

If the driver class can't be resolved this line will throw ClassNotFoundException and you will know that you didn't properly include db2jcc4.jar in your CLASSPATH.

Note that once you take care of all the above, your DriverManager.getConnection() call, the way you wrote it, will still throw exception (different though) for the following two reasons:

1) You didn't include user credentials. Either include them in the connection URL string directly, or add them as user and password properties to a java.util.Properties object, which you will then need to specify as the second argument in the DriverManager.getConnection() call.

2) Specify semicolon at the end of the connection URL. Your URL is ending with "sslConnection=true" and it should end with "sslConnection=true;" otherwise you will get exception indicating invalid URL syntax.