Results 1 to 3 of 3

Thread: Jsp Problem

  1. #1
    Peter is offline Senior Member
    Join Date
    Jun 2007
    Posts
    119
    Rep Power
    0

    Default Jsp Problem

    I have these code but can't access to the database. Please tell me the problem:

    Java Code:
    <html>
    
    <head>
    <title>Validate</title>
    </head>
    
    <body>
    
    <form action="Validate.jsp">
    	<table border="0" width="100%" cellspacing="5" cellpadding="5" id="table1">
    		<tr>
    			<td>
    			<p align="right">User Name : </td>
    			<td width="472"><input type="text" name="txtUser" size="20"></td>
    		</tr>
    	</table>
    	<p align="center"><input type="submit" value="Submit" name="submit"></p>
    </form>
    
    </body>
    
    </html>
    The Bean

    Java Code:
    package test;
    import java.io.*;
    import java.io.Serializable;
    import java.sql.*;
    import java.util.*;
    
    public class Bean {
        public String user;
        public Vector result;
        public void setID(String user){
            this.user=user;
        }
        public String getID(){
            return(this.user);
        }
        
        public Vector getData(){
            Vector v=new Vector();
            try{
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con=DriverManager.getConnection("jdbc:odbc:MyAuctionDatabase");
                PreparedStatement ps=con.prepareStatement("SELECT * FROM Registered_Users_Information WHERE UserName=?");
                ps.setString(1,user);
                ResultSet rs=ps.executeQuery();
                if(rs.next()){
                    v.addElement(rs.getString("UserName"));
                    v.addElement(rs.getString("Password"));
                }
            }catch(Exception ex){
                ex.printStackTrace();;
            }
            this.result=v;
            return result;
        }
    }
    what is the problem?

  2. #2
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default

    Did you create MyAuctionDatabase as ODBC Data source ?

  3. #3
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •