Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder adarshakb's Avatar
    Join Date
    Jun 2009
    Location
    Silicon valley of india
    Posts
    247
    Thanks
    11
    Thanked 1 Time in 1 Post

    Thumbs down Connection to database failed

    Hi there, I am trying to connect to database in java and i succeded using the below details.. connected to IBM DB2 database with java
    Code:
    type = "com.ibm.db2.jcc.DB2Driver";
    String url = "jdbc:db2://localhost:50000/POLICE";
    (with user name and password)
    Class.forName(type); 
    c = DriverManager.getConnection(url,user,pass);
    But the same code fails in a JSP page (when i create a bean object and connect it ) when run on websphere server. Whats wrong?
    The error given is "Driver manager not found"

    By the way the "lib" folder inside WEB-INF folder is empty (but the class files are there in classes/policeLibrary folder

    My bean sentence and java code is as follows
    Code:
    <jsp:useBean id="test" class="policeLibrary.Common"></jsp:useBean>
    <%
    test.addZone("ssssss");
     %>
    Note: addZone works when run as a standalone java application. And INSIDE addZone my connection to database is called.
    Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.

    Albert Einstein
    -----------------------------------------------------
    My Blog songs

  • #2
    New Coder
    Join Date
    Jan 2011
    Location
    India
    Posts
    31
    Thanks
    0
    Thanked 4 Times in 4 Posts
    This a very unlikely error.
    TRy putting your jar files in the lib folder and see what happens

  • #3
    Regular Coder adarshakb's Avatar
    Join Date
    Jun 2009
    Location
    Silicon valley of india
    Posts
    247
    Thanks
    11
    Thanked 1 Time in 1 Post
    There was some importing error itseams and we were importing db2jcc.jar and db2jcc4.jar both

    But had to import ANY one ONLY!!!! WTF! :P my bad...
    Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.

    Albert Einstein
    -----------------------------------------------------
    My Blog songs

  • #4
    New Coder
    Join Date
    Jan 2011
    Location
    India
    Posts
    31
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Put those jars one by one and see whether your errors goes off or not.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •