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 7844235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:48:50+00:00 2026-06-02T16:48:50+00:00

I’m trying to implement a Log In system from my Android application to a

  • 0

I’m trying to implement a Log In system from my Android application to a database stored in MS SQL Server 2008. Connection to the server works, the problem comes when I call logIn method for users to connect on connection helper class to compare password matching.

This is the function that is executed when log in button is clicked:

public void onLogInButtonClicked(View v){
        final EditText login = (EditText) findViewById(R.id.login);
        final EditText password = (EditText) findViewById(R.id.password);

        String userName = login.getText().toString();
        String pass = password.getText().toString();
        System.out.println("Pass Entered:" + pass);
        System.out.println("User Entered" + userName);


        if (connector.logIn(userName, pass)){

            //Creates Intent from new Activity to be launched
            Intent k = new Intent(this, MainActivity.class);

            //Sends login name to activity k
            k.putExtra("loginName", userName);
            //Starts new Activity
            startActivity(k);


        }
        else
        {
            //toast log in unsuccessful
        }
    }

logIn method on Connector class is as follows:

boolean logIn(String name, String password){
        System.out.println("I'm in LogIn method");
        java.sql.ResultSet result = null;
        boolean log = false;
         try {
             connection = this.getConnection();
             if (connection != null) {

                    //String for the login query
                    String statement = "SELECT Password FROM Users WHERE UserName = '" 
                                    + name + "'";      
                    System.out.println(statement);

                    Statement select = connection.createStatement();
                    result = select.executeQuery(statement);
                    System.out.println(result.getString(1));
                    if(result.getString(1) == password) log = true;

                    result.close();
                    result = null;
                    closeConnection();
             } 
             else {
                    System.out.println("Error: No active Connection");
                    return log;
             }
         }  catch (Exception e) {
             e.printStackTrace();
            }
        return log;
    }

I don’t even get to see the “I’m in logIn method” in the console, which makes me guess the app crashes before getting into it, although the crash occurs in the line where the method is called.

Here is the log:

04-25 23:32:45.855: E/AndroidRuntime(795): FATAL EXCEPTION: main
04-25 23:32:45.855: E/AndroidRuntime(795): java.lang.IllegalStateException: Could not execute method of the activity
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.view.View$1.onClick(View.java:2144)
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.view.View.performClick(View.java:2485)
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.view.View$PerformClick.run(View.java:9080)
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.os.Handler.handleCallback(Handler.java:587)
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.os.Looper.loop(Looper.java:123)
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.app.ActivityThread.main(ActivityThread.java:3683)
04-25 23:32:45.855: E/AndroidRuntime(795):  at java.lang.reflect.Method.invokeNative(Native Method)
04-25 23:32:45.855: E/AndroidRuntime(795):  at java.lang.reflect.Method.invoke(Method.java:507)
04-25 23:32:45.855: E/AndroidRuntime(795):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-25 23:32:45.855: E/AndroidRuntime(795):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-25 23:32:45.855: E/AndroidRuntime(795):  at dalvik.system.NativeStart.main(Native Method)
04-25 23:32:45.855: E/AndroidRuntime(795): Caused by: java.lang.reflect.InvocationTargetException
04-25 23:32:45.855: E/AndroidRuntime(795):  at java.lang.reflect.Method.invokeNative(Native Method)
04-25 23:32:45.855: E/AndroidRuntime(795):  at java.lang.reflect.Method.invoke(Method.java:507)
04-25 23:32:45.855: E/AndroidRuntime(795):  at android.view.View$1.onClick(View.java:2139)
04-25 23:32:45.855: E/AndroidRuntime(795):  ... 11 more
04-25 23:32:45.855: E/AndroidRuntime(795): Caused by: java.lang.NullPointerException

Thanks in advance!

  • 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-02T16:48:51+00:00Added an answer on June 2, 2026 at 4:48 pm

    Sounds like your connector object is null. Did you forget to initialize it or scope it incorrectly? Post up where connector is initialized if that wasn’t enough to help you find it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.