0
votes

While running a login program, I am using Apache Tomcat 7.0, JDK 7, JRE 7, Eclipse Juno, and Oracle Database 10g Express Edition

 #login2.jsp
 <body>
    <div class="content">
        <ul>
            <li><a href="header1.jsp">Home</a></li>
            <li><a href="about.jsp">About Us</a></li>
            <li><a href="login.jsp">Booking</a></li>
            <li><a href="registration1.jsp">Registration</a></li>
            <li><a href="Gallery.jsp">Gallery</a></li>
            <li><a href="package1.jsp">Packages</a></li>
            <li><a href="logout.jsp">Logout</a></li>
        </ul>
    </div>
    <div class="right">
        <form action="Login2_back.jsp" method=post>
            <table>
                <tr>
                    <th>5 STAR HOTEL LOGIN</th>
                </tr>
                <tr>
                    <td>
                        <input type="text" name=n1 placeholder="User Id">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="password" name=n2 placeholder="Password">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" name="action" value="SIGN IN">
                    </td>

                </tr>
                <tr>
                    <td align=center><b>NEW USER</b></td>
                </tr>
                <tr>
                    <td>
                        <center><a href="registration1.jsp">REGISTER HERE</a> </center>
                    </td>
                </tr>
            </table>
            <tr>
                <td><a href="search.jsp">search</a>
                    <a href="update.jsp">update</a> </td>
            </tr>
        </form>
    </div>
    </div>
</body>

#Login2_back.jsp

<%@page import="java.sql.*" %>
<%@page import="pack.Dao" %>
<body>
    <% try { Connection con=Dao.dbconnect(); Statement stmt=con.createStatement(); 
String z=r equest.getParameter( "n1"); 
String x=r equest.getParameter( "n2"); 
ResultSet rs=stmt.executeQuery( "select userid,password from login where userid='"+z+ "' and password='"+x+ "'"); i
f(rs.next()) { %>
        <jsp:forward page="header1.jsp" />
    <% } else System.out.println( "Sorry Invalid  user and password"); %>
        <jsp:forward page="header1.jsp" />
    <% } catch(Exception e) {out.println(e);} %>
</body>

In cmd I connected to the database and I created a table login with `userid=sagar` and `password=sinha`

USERID               PASSWORD
-------------------- --------
sagar                sinha

after I commit;

But when I am going to login page using above code `login2.jsp`, using       `userid:sagar` and `password:sinha`, I got the error

java.sql.SQLException: ORA-00942: table or view does not exist 



#Dao.java
package pack;
import java.sql.Connection;
import java.sql.DriverManager;
public class Dao{
private static Connection con;
public static Connection dbconnect()
{
    try{

Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr","hr,"");
    }catch (Exception e){
        System.out.println(e);
        //TODO: handle exception
    }
    return con;
 }
}

This is the connection i used to connect to the database oracle 10g express edition but when i am login it shows

java.lang.NullPointerException..

i did not get the error why it is coming everthing is correct in the program and successfully connected to the database . sqlplus /nolog then conn hr/hr,, connected cr

2

2 Answers

0
votes

This error is that you are making a query on a table or view that doesn't exists on your database schema,you have that login table?

0
votes

error is pretty straight forward. table does not exist, check your DAO class and confirm the connection string if it is connecting to the right database, then from there see if the login table exist