Hey lads,

Firstly apologies for the long message. I just thought it might be easier to explain my issues. I'm doing a website for myself and have been getting some amazing info from this forum.

I've moved onto the database part to it. Now, for my website, user can sign up to avail of my service. I have actually created a link between the forms and MySQL with .JSP and I can store information in my database as inputted by the user.

Now the next part involves when a user signs in with a username and a password. I would like to send it to the database to check if the username matches any usernames in database. If not, a page will display that "the info was not found, please try again". If the information was found, the page will display "Welcome user". I have the basic code below but i'm a bit stuck with a few things. I'll discuss this as i explain my code.

Below is the first page where it prompts the user to enter details. No major problems here. Once entered, the retrieveInfo page will pop up. P.s I just took the code that matters.

<form name="form1" method="POST" action="retrieveInfo.jsp" onSubmit="return validateSignIn(form1)">
      <span class="style3">Username</span> 
      <input type="text" name="username" />
    <label><span class="style3">Password</span>
    <input type="password" name="pass1" />
    <input type="submit" value="Submit Details" name="submit"/>

The next piece of code is retrieveInfo.jsp. This is where i have my first problem so just to let you know, the code will be incorrect. I have highlighted where I think im getting it wrong. This takes the info from the first page and puts it through the javabean 'retAdminBean'-next piece of code after this.

What I also want it to do is to go into the JDBC page (last piece of code) and then onto the database. This is where my first problem lies. I don't know how to pass it into my jdbc page. I put in the line detail.insertAdmin(newAdmin), just to highlight my problem in case anyone could help me.

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
      String username = request.getParameter ("username");
      String pass1 = request.getParameter ("pass1");
      retAdminBean newAdmin = new //retAdminBean is javabean code retAdminBean(username,pass1);
      getUser details = new getUser();//getUser is JDBC page
     [B] details.insertAdmin(newAdmin);[/B]//attempting to insert details from javabean into JDBC page. Not sure how to do it.



Next is the javabean retAdminBean. No problems here.

public class retAdminBean implements java.io.Serializable {

    private String username;
    private String pass1;
    public retAdminBean(String _username,String _pass1) {

        this.username = _username;
        this.pass1 = _pass1;

    public String getUsername() {
        return this.username;

    public void setUsername(String username) {
        this.username = username;

    public String getPass1() {
        return this.pass1;

    public void setPass1(String pass1) {
        this.pass1 = pass1;


The final piece of code is the jdbc file which will check the database. Again, this code is not correct.What I want to happen here is that my values are inputted into here and they are checked against the info in the database to see whether any values match. The problem is, I haven't displayed how to insert the details from the retrieve info page. I've been reading up on JDBC and find it hard to grasp so any help here would be greatful

Also I need to figure out how to return info to display to the user whether values are correct or not. I realise this is probably a whole different kettle of fish but any help again would be appreciated.

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import beans.retAdminBean;

public class getUser {
    public static void main(String[] args){

        Connection c = DBConnection.getConnection();
        Statement st = c.createStatement();

        ResultSet rs = st.executeQuery("select * from user where username=" + retAdminBean.username
                + retAdminBean.pass1);

            String i = rs.getString("username");
            String j = rs.getString("pass1");
            System.out.println("Username : " + i + j);
    }catch(SQLException e){
7 Years
Discussion Span
Last Post by ds2r

I'm not familiar with the other codes but since this is mysql forums, I think you have a problem in your query.

select * from user where username=" + retAdminBean.username+" and password="+ retAdminBean.pass1");

I think that could work

Edited by ds2r: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.