Results 1 to 11 of 11
  1. #1
    shuklagirish is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default JDBC Error in servlet

    Hi,

    I have a simple servlet code which is trying to connect to MS access database 2010 version, but i am getting following error,

    "Driver loaded [Microsoft][ODBC Microsoft Access Driver] System resource exceeded."

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    Connection conn=DriverManager.getConnection("jdbc:odbc:NewTes t");

    and i also tried with

    Connection conn=DriverManager.getConnection("jdbc:odbc:Driver ={Microsoft Access Driver (*.mdb)};DBQ=D:/Banks/IAHC/Database/Test.mdb");

    It gives error on DriverManager.getConnection line.

    Please suggest me,what i can do.

    Thanks,

  2. #2
    pawdlk is offline Member
    Join Date
    May 2011
    Posts
    7
    Rep Power
    0

    Default

    Could you post a function that you have written in a code tags ? - it will be easier to spot the issues.

  3. #3
    shuklagirish is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default

    The same is called for both doGet and doPost functions.

    I dont know if there is some configuration to be done on Glassfish v2 Server or in my ms access file.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    Access can only have a single connection open at any one time, so I would guess either you're trying to open more than one in one go in your app, or something else already has it open.

    Access is not something to use in web apps for this very reason.

  5. #5
    shuklagirish is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default

    Thanks alot for your reply,

    I am opening only 1 connection in my code and its not happening.

    Can i check for connection state in my code, like if it is open then close the connection and then i will get a new connection or Is there any other way to do this? I have got only option of MS access as we have taken license for it.



    Thanks,

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    Nope.
    Which is why Access is a poor choice.

    Since this a web app you do not have "only one connection", unless you have synchronised your servlet somehow. Of course, you haven't given us any code to look at...

  7. #7
    shuklagirish is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default

    I have given you the code in my 1st post, anyways this is my code,

    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.sql.*;

    public class NewServlet extends HttpServlet {


    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    Connection conn=null;
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    out.println("Driver loaded");


    // String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.accdb)};DBQ=D:/Test.accdb;DriverID=22;READONLY=true}";

    // conn = DriverManager.getConnection( database);

    conn = DriverManager.getConnection( "jdbc:odbc:Test");
    if(conn!=null)
    {
    out.println("Connection established");
    }
    else
    {
    out.println("Unable to establish gthe connection");
    }
    PreparedStatement ps=conn.prepareStatement("select * from Test where [ID]=1");
    ResultSet rs=ps.executeQuery();
    if(rs.next())
    {
    out.println(rs.getString(2));
    }

    //conn=DriverManager.getConnection("jdbc:odbc:IntlAs sets");
    }
    catch(Exception ee)
    {
    out.println("Exception :: "+ee.getMessage());
    }
    finally {
    out.close();
    }
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    }

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    And whenever you hit this from your browser you get that error?
    And after restarting the web server?
    Rebooting the machine?
    When does this happen?

    I'm asking this because you never close that connection you open...

  9. #9
    shuklagirish is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default

    Yes, i tried restarting the server and the PC also 2 times but the problem was not solved.

    From the very first time i executed this i got the same error and has always been getting the same problem. When i tried same thing on simple command based java it works fine.

    Can this issue be related to Galssfish server? its having less resource or something?

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    Possibly Glassfish related.
    I've never used it.
    It might be pooling connections by default.

    You're still not closing that connection, though.

    ETA: But that connection is coming from Access...

  11. #11
    shuklagirish is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default

    That connection was never ever opened, it has always gave me error on that DriverManager.getConnection line, it hasnt worked single time also.

Similar Threads

  1. Jdbc and servlet
    By ulferik in forum New To Java
    Replies: 1
    Last Post: 03-26-2011, 09:01 AM
  2. Servlet JDBC
    By kevinnrobert in forum Java Servlet
    Replies: 1
    Last Post: 04-02-2010, 01:27 PM
  3. Replies: 2
    Last Post: 12-09-2009, 09:58 AM
  4. Replies: 0
    Last Post: 04-01-2008, 10:17 AM
  5. Replies: 0
    Last Post: 09-28-2007, 12:56 PM

Tags for this Thread

Posting Permissions

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