
*while doing connectivity of jdbc with servlet I m getting following error how can I solve it.
*database is saved in classes where .java and .class file is stored.
*I have done settings of Odbc driver as follows
1)control panel-> administrative tools->ODBC driver->add ->Microsoft Access Driver(*.mdb)->finish->Typed source name->clicked on select- took respective path where database was saved-> ok->ok->ok.
***********My code is********
<html>
<body>
<form action="servlet/Samplem"method=GET>
Model No=<input type=text name=mdlno><br>
Mobile Name=<input type=text name=mblnm><br>
Price=<input type=text name=prc><br>
<input type=submit>
</form>
</body>
</html>
***************java code***************
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Samplem extends HttpServlet implements Servlet
{
public void doGet(HttpServletRequest rq,HttpServletResponse rs)throws ServletException,IOException
{
PrintWriter pw=rs.getWriter();
PreparedStatement pst;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
pw.println("Class loaded");
Connection cn=DriverManager.getConnection("jdbc:odbc:{Microsoft Access Driver(*.mdb)}");
pw.println("connected");
pst=cn.prepareStatement("insert into mobile values(?,?,?)");
String Mdlno=rq.getParameter("mblno");
String Mbnm=rq.getParameter("mbnm");
String price=rq.getParameter("price");
pst.setInt(1,Integer.parseInt(Mdlno));
pst.setString(2,Mbnm);
pst.setInt(3,Integer.parseInt(price));
pst.executeUpdate();
pw.println("Inserted");
pst.close();
cn.close();
}
catch(Exception e){pw.println("error"+e);}
}
}
****************output**************
Class loaded
errorjava.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified


Hi problem with url this url jdbc:odbc:{Microsoft Access Driver(*.mdb)}
First set the datasoruce name in conntrollpannel->Administrative tools -> Datasource(ODBC) -> User DSN-> Add -> select the Microsoft Access Driver(*.mdb) -> finish -> enter some userdefine datasource name like msdsn -> ok.
and use that datasource name in url like
jdbc:odbc:msdsn

i tried the program,but still the connectivity with database is not happening. The Driver is getting Loaded.

Thank u for you solution
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.