Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    NJ
    Posts
    1

    Post Unanswered: JDBC/ODBC Connection Failed error in Tomcat

    I am trying to connect to an Access Database using Java. I am a freelance programmer and Can not insert etc right now into this Database. It is due in a month and can not continue programming cause of connectin error: Microsoft ODBC Driver Manager Data Sourc name not found...Driver specified Java SQL Exception""""""


    Code below: System out print lines tell me it fails after the url...please help!!!

    import java.sql.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    public class MakeConnection extends HttpServlet
    {

    MakeConnection()
    {
    loadAccessJDBCDriver();
    }
    public static void loadAccessJDBCDriver()
    {
    try{
    DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
    System.out.println ("Loading Database driver...");
    }
    catch(SQLException e)
    {
    System.err.println(e.getMessage() + "\n" + e.toString());
    }
    }
    public static Connection getConnected()
    {
    try{
    System.out.println("Before Connected");
    String jdbc_url = "jdbcdbc:Polite";
    System.out.println("Connected 3");
    Connection conn = DriverManager.getConnection(jdbc_url);
    //Connection conn = DriverManager.getConnection(jdbc_url, "Scott", "Tiger");
    System.out.println("Connected");

    return conn;

    }
    catch(SQLException e)
    {
    System.err.println(e.getMessage() + "\n" + e.toString());

    }
    return null;
    }
    public static Statement makeStatement(Connection conn)
    {
    try{
    Statement stmt = conn.createStatement();
    return stmt;
    }
    catch(SQLException e)
    {
    System.err.println(e.getMessage() + "\n" + e.toString());
    }
    return null;
    }
    public static void closeThingsDown(Statement stmt, Connection conn)
    {
    try{
    stmt.close();
    conn.close();
    }
    catch(SQLException e)
    {
    System.err.println(e.getMessage() + "\n" + e.toString());
    }

    }
    public static ResultSet openResultSet(Statement stmt, String query)
    {
    try{

    ResultSet rs = stmt.executeQuery(query);

    return rs;
    }
    catch(SQLException e)
    {
    System.err.println(e.getMessage() + "\n" + e.toString());
    }
    return null;

    }
    }
    Last edited by Daria; 11-03-03 at 09:31.

  2. #2
    Join Date
    Nov 2003
    Location
    Bangalore
    Posts
    1

    did you get any answers

    Hi,

    I am facing the same problem. Did you get any answers for your question ? If you ahve got an answer, let me know.

    Thanks in advance.

    Rohit.

  3. #3
    Join Date
    Nov 2003
    Location
    Jakarta, Indonesia
    Posts
    32
    change the e.getMessage() to e.printStackTrace()
    and post the stack trace

Posting Permissions

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