0

please any one help me to clarify my doubts.....

By running my servlet program which having ODBC connection...... It shows an error as [Microsoft][ODBC Driver Manager] Data Source name not found and no default driver specified...

Following procedure only i did...

1)I did servlet program by having JDBC connection in my program in ROOT-WEB-INF- then i creayte separate folder name as classes in tomcat and in web i wrote the corresponding coding
2)then i create path file and i compile my program(below i given that coding for ur reference)

3)I made an ODBC connection as
control panel--administrative tools--ODBC--user dsn--(add)--Microsoft access driver (*.mdb)--datasourse name lg--add--(then i choose my db)

4)I run the TOMCAT

5)then i run my html coding in that i enter username and password then i submit

6)it display as [Microsoft][ODBC Driver Manager] Data Source name not found and no default driver specified...


program as

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
        Connection conn;
        String qr1;
        public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
        {
                PrintWriter o;
                qr1="";
                String user=req.getParameter("user");
                String pass=req.getParameter("pass");
                res.setContentType("text/html");
                o=res.getWriter();
                o.println("<html><head><title>KPK");
                o.println("</title></head><body>");
                try
                {
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        conn=DriverManager.getConnection("jdbc:odbc:lg");
                        Statement st=conn.createStatement();
                        ResultSet rs=st.executeQuery("select user,pass from valid where user='"+user+"' and pass='"+pass+"'");
                        if(rs.next())
                        {
                                o.println("Username and Passwoed is Correct");
                        }
                        else
                        {
                                o.println("Not a Valid User or Password");
                        }
                        rs.close();
                        o.println("</body></html>");
                        conn.close();
                        o.close();
                }
                catch(Exception e)
                {
                        o.println(e.getMessage());
                }
        }
}

html coding is

<html>
<head>
<title>User Screen</title>
</head>
<body bgcolor="pink" text="red">
<I><h2 align="center">LOGIN PAGE</h2></I>

<form action="http://localhost:8080/kpk/Login" method=post>
	<hr>
	<table border=15 align="center" bgcolor="green">
	<tr>
	<td>User Name  
	<td><input type="text" name="user" size=10>
	</tr>
	<tr>
	<td>Password  
	<td><input type="password" name="pass" size=10>
	</tr>
	<tr>
	<td colspan=2 align="center"><input type="Submit" value="Send">
	</tr>   
	</table>
	<hr>
</form>
</body>
</html>

Edited by peter_budo: Keep It Clear - Do use code tags when posting any code

2
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by cvanithakpm
0

Properly configure your web caontainer's configuration pool and use jndi to access it. See the JEE tutorials and/or your web container's documentation.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.