Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:59:05+00:00 2026-06-17T10:59:05+00:00

I am trying to create my first MySQLConnection in Eclipse and am getting an

  • 0

I am trying to create my first MySQLConnection in Eclipse and am getting an error on authenticateUser of “Multiple markers at this line
– The return type is incompatible with
DBConnection.authenticateUser(String, String)”

I understand this means “that there is more than one error … but I can’t solve the issue…”.

I am using http://altair.cs.oswego.edu/~tenberge/tenbergen.org/misc/DB-Access-in-GWT-The-Missing-Tutorial.pdf as my guide.

This is my code:

AwardTracker.gwt.xml

<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.user.theme.standard.Standard"/>
<entry-point class="org.AwardTracker.client.AwardTracker"/>

<!--  servelet context - path is arbitrary, but must match up with the rpc init inside java class -->
<!--  Tomcat will listen for this from the server and waits for rpc request in this context -->
<servelet class="org.AwardTracker.server.MySQLConnection" 
    path="/MySQLConnection" />
    <inherits name="com.google.gwt.user.theme.standard.Standard"/>
    <inherits name="com.google.gwt.user.theme.chrome.Chrome"/>
    <inherits name="com.google.gwt.user.theme.dark.Dark"/>

User.java

package org.AwardTracker.client;

import com.google.gwt.user.client.rpc.IsSerializable;

public class User implements IsSerializable {
@SuppressWarnings("unused")
private String username;
@SuppressWarnings("unused")
private String password;
@SuppressWarnings("unused")
private User() {
    //just here because GWT wants it.
}
public User(String username, String password) {
    this.username = username;
    this.password = password;
}

}


MySQLConnection.java

package org.AwardTracker.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import org.AwardTracker.client.DBConnection;
import org.AwardTracker.client.User;

public class MySQLConnection extends RemoteServiceServlet implements DBConnection {
private Connection conn = null;
private String status;
private String url = "jbdc:mysql://localhost/awardtracker";
private String user = "DBuser";
private String pass = "DBpass";
public MySQLConnection() {
    try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        conn = DriverManager.getConnection(url, user, pass);
    } catch (Exception e) {
        //NEVER catch exceptions like this
    }
}

public int authenticateUser(String user, String pass) {
    User user;
    try {
        PreparedStatement ps = conn.prepareStatement(
            "select readonly * from users where username = \"" + user  + "\" AND " + "password = \"" + pass + "\"");
            ResultSet result = ps.executeQuery();
            while (result.next()) {
                user = new User(result.getString(1), result.getString(2));
            }
            result.close();
            ps.close();
        } catch (SQLException sqle) {
            //do stuff on fail
        }
        return user;
}

}

Any help would be greatly appreciated.

Regards,

Glyn

Hi BenvynQ,

Thanks for your help. Just goes to show that these tutorials are not perfect. I made this change and now I get an error within authenticateUser:

while (result.next()) {
user = new User(result.getString(1), result.getString(2));
}

Of “The constructor User(String, String) is undefined”.

Thanks,

Glyn

Hi Bevnq,

Thanks awfully for your help. I think there were a few “}” missing so I have modified as following.

Also, you say “User user = null; // necessary unless you do something in the exception handler
“. My impression of this is that we are trying to find out if the user is in the table and return an exception if they are not (i.e., verify the username and password). Therefore, the return needs to be a confirmation and therefore we are doing something with the exveption handler. I am obviously missing something; so how do we know the user has logged in successfully?

Also, Eclipse does not seem to have an issue with mixed case for the package as I am doing this in stages and all has worked up to adding this.

Regards,

Glyn

package org.AwardTracker.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import org.AwardTracker.client.DBConnection;
import org.AwardTracker.client.User;

public class MySQLConnection extends RemoteServiceServlet implements DBConnection {
    private Connection conn = null;
private String status;
private String url = "jbdc:mysql://localhost/awardtracker";
private String user = "DBuser";
private String pass = "DBpass";
public MySQLConnection() {
    try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        conn = DriverManager.getConnection(url, user, pass);
    } catch (Exception e) {
        //NEVER catch exceptions like this
    }
}

public User authenticateUser(String userName, String pass) {
    User user = null; // necessary unless you do something in the exception handler
    ResultSet result = null;
    PreparedStatement ps = null;
    try {
      ps = conn.prepareStatement(
          "select readonly * from users where username = \"" + userName  + "\" AND "    + "password = \"" + pass + "\"");
      result = ps.executeQuery();
      while (result.next()) {
         user = new User(result.getString(1), result.getString(2));
      }
    } 
    catch (SQLException sqle) {
      //do stuff on fail
    }
    finally {
        if (result != null) {
            try {
                result.close();
            }
            catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (ps != null) {
            try {
                ps.close();
            }   
            catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
return user;
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:59:06+00:00Added an answer on June 17, 2026 at 10:59 am

    You have defined the method

    public int authenticateUser(String user, String pass) {
    

    yet the object you are returning is

    User user;
    

    reading the tutorial looks like you should have declared the method

    public User authenticateUser(String userName, String pass) {
        User user = null; // necessary unless you do something in the exception handler
        ResultSet result = null;
        PreparedStatement ps = null;
        try {
          ps = conn.prepareStatement(
              "select readonly * from users where username = \"" + userName  + "\" AND " + "password = \"" + pass + "\"");
          result = ps.executeQuery();
          while (result.next()) {
             user = new User(result.getString(1), result.getString(2));
          }
        } catch (SQLException sqle) {
          //do stuff on fail
        }finally{
            if (result != null) {
                try {
                    result.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                    e.printStackTrace();
            }
        }
    return user;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create my first GUI application using (Java + Eclipse +
I'm trying to create a simple threading procedure (granted this is my first attempt
I am trying to create my first Windows phone application but I keep getting
I am trying to create my first C++ exeecutable using Eclipse IDE (using Windows
I am just trying to create my first repo from Ubuntu 11.10 with this
I am getting an error when trying to create a relationship within two tables
Trying to create the first project. First got the below error when I ran,
This is my first stab at trying to create a JQuery plugin, so I
I am trying to create my first Android app. I am using Eclipse. I
I am trying to create my first C++ executable program with Eclipse in Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.