Results 1 to 5 of 5
  1. #1
    illusion1912 is offline Member
    Join Date
    Jan 2009
    Posts
    5
    Rep Power
    0

    Default Jdbc problem.Help Needed

    mport java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class Jdbc extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");

    Connection con = DriverManager.getConnection(
    "jdbcracle:thin:@localhost:8080:abhishek","sco tt ","tiger");
    // @machineNameort:SID, userid, password

    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>Test JDBC Connection</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("<H1>Connection Established Successfully</H1>");
    out.println("</BODY>");
    out.println("</HTML>");

    } catch (ClassNotFoundException e1) {
    out.println("Connection Failed " + e1.toString());
    } catch (SQLException e2) {
    out.println("Connection Failed " + e2.toString());
    } catch (Exception e3) {
    out.println("Connection Failed " + e3.toString());
    }
    }

    }
    this is my code. My Sid is abhishek. am using oracle 9i.apache tomcat application server.But the problem i am facing is i am getting "Connection Failed java.sql.SQLException: Io exception: Got minus one from a read call "... Please help!!!!

  2. #2
    racerxadam is offline Member
    Join Date
    Jul 2008
    Posts
    68
    Rep Power
    0

    Default

    I think you have a typo in your connection string try
    Java Code:
    "jdbc:oracle:thin:@localhost:8080:abhishek"

  3. #3
    illusion1912 is offline Member
    Join Date
    Jan 2009
    Posts
    5
    Rep Power
    0

    Default No help!!!

    have tried it.. but to no avail...what exactly should be the config in server.xml.. what jars do i have to place there? Please help!!!!:(

  4. #4
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

    Default

    which kind of JDBC drivers are you using?
    OCI or Thin Driver
    Last edited by mtyoung; 01-09-2009 at 06:52 AM.

  5. #5
    racerxadam is offline Member
    Join Date
    Jul 2008
    Posts
    68
    Rep Power
    0

    Default

    It might be more helpful if your exception messages were different depending on which exception is thrown. It looks like your code can't find the driver class. Somehow you need to get your driver jar on the classpath of the jvm

    And please don't cross post in other forums

Similar Threads

  1. Problem in JDBC
    By Preethi in forum New To Java
    Replies: 11
    Last Post: 01-08-2009, 06:18 PM
  2. Jdbc problem
    By abhiN in forum JDBC
    Replies: 1
    Last Post: 03-21-2008, 06:10 AM
  3. JDBC problem
    By Swamipsn in forum New To Java
    Replies: 1
    Last Post: 08-13-2007, 07:05 PM
  4. JDBC Driver problem
    By Swamipsn in forum New To Java
    Replies: 3
    Last Post: 08-09-2007, 04:55 PM
  5. JDBC problem
    By peiceonly in forum Threads and Synchronization
    Replies: 2
    Last Post: 08-03-2007, 02:42 PM

Posting Permissions

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