Results 1 to 3 of 3
Thread: Jsp Problem
- 06-28-2007, 03:52 PM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 119
- Rep Power
- 0
Jsp Problem
I have these code but can't access to the database. Please tell me the problem:
The BeanJava 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>
what is the problem?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; } }
- 07-04-2007, 02:03 PM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 130
- Rep Power
- 0
Did you create MyAuctionDatabase as ODBC Data source ?
- 07-04-2007, 02:03 PM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 164
- Rep Power
- 6


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks