Hai Friends,
While designing a Login
servlet I could not get connection with the ODBC datasource. My code is as follows:
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Simple 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>");
String title = "Welcome to MailServer";
out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body>");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
out.println("Class done<br>");
Connection conn = DriverManager.getConnection("jdbc
dbc:mail");
out.println("Connection done<br>");
Statement st = conn.createStatement();
st.executeUpdate("insert into User(loginname,password) values('"+request.getParameter("lname")+"','"+request.getParameter("pass")+"')");
st.close();
conn.close();
}
catch(Exception e)
{
out.println("Exception Has Been Caught <br>" + e);
}
out.println("</body>");
out.println("</html>");
}
}
The error which i get is:
Exception Has Been Caught
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I tried the same connection in a simple
java program and there is no problem with it. Is there some thing to be added while using in Servlet. I am using
TOMCAT server.
Archana S