Results 1 to 3 of 3
  1. #1
    kenmat514 is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default Eclipse MySQL query

    Good day people of Java Forums. I have a little bit of a problem. I am trying to code a java file to authenticate login information from MySQL and it will output a boolean value to the other java file. All of the underlined words show a "cannot be resolved" message and I can't seem to know why. Any kind of help would be appreciated. Thanks!

    import java.util.*;
    import java.sql.SQLException;
    import java.sql.*;
    import _____________.model.Users;

    public class SQLAuthenticator {
    public static boolean confirmLog(Users users) throws SQLException {
    String verify= "SELECT username from users where username = ? and password = ?";
    boolean match = false;

    try {
    initializeDbConnection(); //establish db connection using Spring

    preparedStatement = connection.prepareStatement(verify);
    preparedStatement.setString(1, users.getUserid());
    preparedStatement.setString(2, users.getPass());
    resultSet = preparedStatement.executeQuery(verify);
    String userdb = "";
    while(resultSet.next()){
    userdb = resultSet.getString("username");
    }

    if (userdb.equals("")){
    match = false;
    }
    else {
    match = true;
    }

    return match;


    }
    catch (SQLException e) {
    throw new SQLException(e);
    }
    }



    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Use code tags, not quote tags, for posting code.
    When posting errors post the full error.
    Where is preparedStatement declared?

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by kenmat514 View Post
    Good day people of Java Forums. I have a little bit of a problem. I am trying to code a java file to authenticate login information from MySQL and it will output a boolean value to the other java file. All of the underlined words show a "cannot be resolved" message and I can't seem to know why. Any kind of help would be appreciated. Thanks!

    don't know why you post a db problem in the eclipse forum, let me know. anyway, if you want to establish a connection to a database perhaps reading this tutorial http://www.java-forums.org/java-tuto...nectivity.html is helpful.
    Last edited by j2me64; 06-23-2011 at 10:42 PM.

Similar Threads

  1. MySQl query taking too much time
    By jessie in forum JDBC
    Replies: 16
    Last Post: 11-11-2010, 01:09 PM
  2. Query MySQL
    By boss in forum Advanced Java
    Replies: 3
    Last Post: 01-04-2010, 09:36 AM
  3. Query MySQL
    By boss in forum Advanced Java
    Replies: 3
    Last Post: 01-04-2010, 09:35 AM
  4. mysql query performance issue
    By gilbertsavier in forum JDBC
    Replies: 0
    Last Post: 08-05-2009, 10:34 AM
  5. MySQL/JDBC Mysql query output
    By thelinuxguy in forum Advanced Java
    Replies: 4
    Last Post: 02-13-2009, 01:57 AM

Tags for this Thread

Posting Permissions

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