Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default Database Connectivity error

    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.awt.*;

    public class orderEx extends HttpServlet {

    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    out.println("<html>");
    out.println("<head>");

    out.println("<title>Invoice Generation</title>");
    out.println("</head>");
    out.println("<body bgcolor=\"white\">");

    String it_no,it_qtt,p_each,fname,lname,mname,addr,cardno, card_type;
    //fetch all parameters
    it_no = request.getParameter("it_no");
    it_qtt = request.getParameter("it_qtt");
    p_each = request.getParameter("p_each");
    fname = request.getParameter("fname");
    mname = request.getParameter("mname");
    lname = request.getParameter("lname");
    addr = request.getParameter("addr");

    card_type= request.getParameter("card_type");
    cardno = request.getParameter("cardno");
    if(it_no==null || it_qtt==null )
    {
    //Show form

    out.println("<form action=\"#\">");
    out.println("<tr><td>it_no</td><td><input type=\"textbox\" name=\"it_no\"></td></tr><br>");
    out.println("<tr><td>Quantity</td><td><input type=\"textbox\" name=\"it_qtt\"></td></tr><br>");
    out.println("<tr><td>Price Each</td><td><input type=\"textbox\" name=\"p_each\"></td></tr><br>");
    out.println("<tr><td>First Name</td><td><input type=\"textbox\" name=\"fname\"></td></tr><br>");
    out.println("<tr><td>Mid Initial</td><td><input type=\"textbox\" name=\"mname\" size=1></td></tr><br>");
    out.println("<tr><td>Last Name</td><td><input type=\"textbox\" name=\"lname\"></td></tr><br>");
    out.println("<tr><td>Address</td><td><input type=\"textbox\" name=\"addr\"></td></tr><br>");

    out.println("<tr><td colspan=2><b>Select Card Type:</br>");

    out.println("<tr><td></td><td><input type=\"submit\" name=\"submit\"></td></tr><br>");

    }
    else
    {
    //validation
    try
    {
    Driver d=(Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDri ver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:odbc:myweb") ;
    Statement stmt=con.createStatement();
    String qry="insert into webtable values('"+it_no+"'+'"+it_qtt+"'+'"+p_each+"'+'"+fn ame+"'+'"+mname+"'+'"+lname+"'+'"+addr+"'+'"+card_ type+"'+'"+cardno+"')";

    int i;
    i=stmt.executeUpdate(qry);
    if(i>0)
    {
    out.println("data inserted successfully");

    }
    else
    {
    out.println("data is not inserted");
    }



    }
    catch(Exception e1)
    {
    out.println(e1.getMessage());
    }
    }


    }



    out.println("</body>");
    out.println("</html>");
    }
    }



    hello please solve my problem,i am vaibhav when i try to insert data to database(ms-access 2007) then it show me error,could you please tel me why?
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    8

    Default

    Is your database driver on your classpath?

  3. #3
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default Database Driver

    can you please elaborate ,what should i have to do with database driver and classpath.when i connect awt code with database then i access it very finely.
    so my question is if im doing database connetivity with servlet then it is compulsary to consider class path.....

  4. #4
    AadiSri is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Default

    Can you show the log file?

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    10

    Default

    Quote Originally Posted by doWhile View Post
    Is your database driver on your classpath?
    Nothing to do with it. If you look, that is using the "intern" JDBC-ODBC Bridge.

    @OP

    Have you defined an ODBC DataSource named "myweb"? Seemingly not. Either do that or use the DNSless ODBC Connection URL (Google that).

Similar Threads

  1. database Connectivity
    By arjun_duddu in forum JDBC
    Replies: 2
    Last Post: 08-29-2010, 04:56 AM
  2. Database connectivity error with Websphere server
    By praveen_1987 in forum Enterprise JavaBeans (EJB)
    Replies: 3
    Last Post: 05-21-2010, 08:33 AM
  3. Database connectivity
    By rajiparth in forum JDBC
    Replies: 1
    Last Post: 04-07-2009, 07:39 PM
  4. database connectivity
    By rilwanfit in forum Networking
    Replies: 1
    Last Post: 03-13-2009, 08:54 PM
  5. database connectivity
    By vani in forum Eclipse
    Replies: 0
    Last Post: 11-21-2008, 11:03 AM

Posting Permissions

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