Topic
  • 2 replies
  • Latest Post - ‏2011-05-28T14:16:43Z by SumaGS
SumaGS
SumaGS
2 Posts

Pinned topic No suitable driver

‏2011-05-26T14:35:13Z |
Hi,

I have a j2ee application deployed on WAS. I use following code to connect to db2 database and it throws "No Suitable Driver found" exception. I have created a shared lib on WAS and have included db2jcc4.jar in the shared lib. Added a reference to it in my application.
Code:

DriverManager.getConnection("jdbc:db2://host:port/dbname", "user", "password");
Do I need to do anything else? Any other jar I need to put in the shared lib? or any other way of putting the jar in classpath?

Appreciate your help

--Suma
Updated on 2011-05-28T14:16:43Z at 2011-05-28T14:16:43Z by SumaGS
  • SystemAdmin
    SystemAdmin
    1731 Posts

    Re: No suitable driver

    ‏2011-05-28T05:34:09Z  
    HI suma...

    I am sathya working as filenet developer.

    Below is the sample code to connect DB2,

    sample Code:
    =====
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    Connection conn = DriverManager.getConnection("jdbc:db2://demo1:50000/OBJST1", "db2admin", "database1");
    if (conn == null)
    System.out.println("Connection failed.");
    else
    System.out.println(" Connection success ");

    Systax:
    =======
    DriverManager.getConnection("jdbc:db2://<host name>:<DB2 port number>/<data base name>", "<user name>", "<password>");
    jar files in classpath:
    =======================
    db2jcc.jar
    db2jcc_license_cu.jar

    i thought that , above are the enough precautions to get the connection from DB2, i hope that it is very help full to you.
  • SumaGS
    SumaGS
    2 Posts

    Re: No suitable driver

    ‏2011-05-28T14:16:43Z  
    HI suma...

    I am sathya working as filenet developer.

    Below is the sample code to connect DB2,

    sample Code:
    =====
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    Connection conn = DriverManager.getConnection("jdbc:db2://demo1:50000/OBJST1", "db2admin", "database1");
    if (conn == null)
    System.out.println("Connection failed.");
    else
    System.out.println(" Connection success ");

    Systax:
    =======
    DriverManager.getConnection("jdbc:db2://<host name>:<DB2 port number>/<data base name>", "<user name>", "<password>");
    jar files in classpath:
    =======================
    db2jcc.jar
    db2jcc_license_cu.jar

    i thought that , above are the enough precautions to get the connection from DB2, i hope that it is very help full to you.
    Hi Sathya,

    Thanks for the response.

    I always tried with the following code.

    Connection conn = DriverManager.getConnection("url", "db2admin", "database1");

    I did not load the driver explicitly. It worked fine for weblogic + db2, weblogic + oracle, WAS + oracle.
    I see "No suitable driver" error only for WAS + DB2 combination.

    But when I load the Driver explicitly, I was able to get the connection. Wondering why explicit loading is required only for WAS + DB2 combination.

    Thanks,
    Suma