Forum Discussion

divman's avatar
divman
Contributor
11 years ago

[Resolved] DB2 Connection Driver Error

Hi,
I know this could be a repeated question posted, but after researched from many threads i am still facing an connection error. I use SoapUI Pro 5.1.1. When i try to connect DB2 database with the below groovy script, i get an cound not find driver error. But when i use the JDBC step and configure with the UI steps, it says Connection successful (but still problem with building query).

Here is my code
import groovy.sql.Sql

try
{
sql = Sql.newInstance( "jdbc:db2://<Server>", "<user>", "<pass>", "com.ibm.db2.jcc.DB2Driver" );
} catch (Exception e)
{
log.info e.message
return
}

log.info "|ENT_CUST_ID| CRETN_TS| CRETN_USER_ID| UPDT_TS|";

sql.eachRow("SELECT * FROM cucrq01.ent_cnsmr WHERE (ENT_CUST_ID >= '101' and ENT_CUST_ID <= '200')")
{ row ->
log.info "|$row.ENT_CUST_ID| $row.CRETN_TS| $row.CRETN_USER_ID| $row.UPDT_TS";
}

sql.close()



when i run this script i get the error like "Tue Aug 26 08:58:45 EDT 2014:INFO:No suitable driver found for jdbc:db2://<Server>". Could anyone help me on this?

6 Replies

  • Hi,

    We do not support custom coding. What errors are you getting when trying to build a query with the JDBC test step?


    Regards,
    Marcus
    SmartBear Support
  • Hi,
    I dint not get any error. When i click ok on the Build Query window, the soapui is hanged. But do not know really it connects to database.

    And Marcus, i understand you will not support custom code. But this is not error from coding logic...it says No Suitable Driver found. When i run this script as separate groovy script (from groovy console editor) it works fine and from SoapUI it is not recognizing the driver. I have the proper jdbc jar files placed in ".../bin/ext" folder. So please help me on the connection problem on why SoapUI is not recognizing the driver files.

    These are the files i have.
    db2jcc4.jar
    db2jcc_license_cisuz.jar
  • Hi,

    Please check the following things and send the .log files in a support ticket or attach here if possible.

    dbc:db2://<hostname>:<port>/<database> for the Universal and Data Server driver for JDBC.

    2) Check if you have DB2 Extended security enabled on the DB2 Client using the command:
    db2set -all

    If enabled, the output will show:
    [g] DB2_EXTSECURITY=YES

    If so, make sure the application userID is part of DB2ADMNS or DB2USERS groups in Windows

    You may need to run SoapUI Pro in administrator mode if you are able to execute your Groovy script from the Groovy console in admin mode.


    Regards,
    Marcus
    SmartBear Support
  • I researched and found from some forums, that if we place the driver jar files in ".../SoapUI Pro 5.1.1/lib" folder it will work. And i did the same, it worked and able to connect to DB2 and query the tables. As far as i know we have to place all the external jar files in "../bin/ext" folder. I tried the same db connection for Microsft SQL Server with having driver jar files in bin/ext folder. But for DB2 instead of bin/ext, if we place in lib folder, soapui connects to backend.

    Any idea why...?
  • Hi,

    I'm not exactly sure why you need DB2 drivers in the <SoapUI Pro install>\lib directory. The fact that this is particular to the DB2 driver is strange. It could be some sort of classpath or classloader issue particular to that driver occurring. I did notice the same problem with the mysql driver I was using with the Groovy groovy.sql.Sql class. If you try the following code with your DB2 driver in the <SoapUI Pro install>\bin\ext directory and the appropiate JDBC DB2 string it should work.


    import java.sql.Connection;
    import java.sql.DriverManager;
    import com.mysql.jdbc.Driver; //import the applicable driver class for your JDBC driver

    try
    {
    String url = "jdbc:mysql://127.0.0.1:3306/test";
    Connection conn = DriverManager.getConnection (url, "user", "password");
    }
    catch(Exception e)
    {
    log.info e.message
    log.info e.stackTrace
    }





    Regards,
    Marcus
    SmartBear Support
  • No luck. Still shows same error message.

    But as of now my problem is solved and i will continue with placing in lib folder (somehow it works). So i am good now. Thanks for your support.