954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

servlet

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>
cvanithakpm
Newbie Poster
21 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

any one plz reply ya

cvanithakpm
Newbie Poster
21 posts since Oct 2011
Reputation Points: 10
Solved Threads: 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.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

sorry i couldnt understand... please make me to clear dear friends...

cvanithakpm
Newbie Poster
21 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

The documentation and tutorials do that. Have you even bothered to read them, yet?

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

oh no not like that.. but i diont know what to read..

cvanithakpm
Newbie Poster
21 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

1. The tomcat documentation, it comes with the tomcat distribution.

2. The JEE tutorials
JEE5 -> http://docs.oracle.com/javaee/5/tutorial/doc/
JEE6 -> http://download.oracle.com/javaee/6/tutorial/doc/

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

1. The tomcat documentation, it comes with the tomcat distribution.

2. The JEE tutorials JEE5 -> http://docs.oracle.com/javaee/5/tutorial/doc/ JEE6 -> http://download.oracle.com/javaee/6/tutorial/doc/


oh ok i ll do..

cvanithakpm
Newbie Poster
21 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You