Thread: Jsp Problem
View Single Post
  #1 (permalink)  
Old 06-28-2007, 04:52 PM
Peter Peter is offline
Senior Member
 
Join Date: Jun 2007
Posts: 119
Peter is on a distinguished road
Jsp Problem
I have these code but can't access to the database. Please tell me the problem:

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

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?
Reply With Quote
Sponsored Links