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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:11:32+00:00 2026-05-27T23:11:32+00:00

I use the following code to retrieve the data from MySql database. GContnStr is

  • 0

I use the following code to retrieve the data from MySql database. GContnStr is a connection method I call to connect to the database.But,when I use this code, I got the following exceptions. How can I solve this problem?

package designstudent;

import java.sql.*;
import java.awt.event.*;
import java.beans.EventHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import java.sql.*;
import java.util.ArrayList;
import java.util.jar.Attributes.Name;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import java.util.ArrayList.*;
import java.util.Vector;
import javax.swing.*;
public class combobutton extends javax.swing.JFrame {

     Statement TmpStmnt=null;
     ResultSet TmpDetlRs=null;
     GContnStr GCS=new GContnStr();
     String   GStrSql=null;


      private  String PFldname="StudClass";
      private  String PTName="studentmaster";



       enum options{
           DBTABLE,
           DBQryDef
                  }

     String PoptnStr;

     options val = options.valueOf(PoptnStr);

    public combobutton() throws SQLException {
        combo(PoptnStr, TmpStmnt, TmpDetlRs, GStrSql, PFldname, PTName);
        initComponents();
    }
public void combo(String PoptnStr,Statement TmpStmnt,ResultSet TmpDetlRs,String StrSql,String PFldName,String PTName) throws SQLException
    {
      cbx1.removeAllItems();
      cbx2.removeAllItems();
      cbx3.removeAllItems();
      String DBTABLE = null;
      try{
        switch(val)
              {
          case DBTABLE:
          case DBQryDef:
               if(PoptnStr==DBTABLE)
               {
                   GCS.GContnStr();
                   GStrSql="select '"+ PFldName+"' from '"+PTName+"'";
                   TmpDetlRs=TmpStmnt.executeQuery(GStrSql);
                    while(TmpDetlRs.next())
                    {
                        String TmpOb1=TmpDetlRs.getString("StudClass");
                        System.out.println(TmpOb1);
                    }

               }
      }
        }
      catch(Exception e){
          System.out.println(e);

      }
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new combobutton().setVisible(true);

                } catch (SQLException ex) {
                    Logger.getLogger(combobutton.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JComboBox cbx1;
    private javax.swing.JComboBox cbx2;
    private javax.swing.JComboBox cbx3;
    // End of variables declaration                   

}

ERROR

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Name is null
        at java.lang.Enum.valueOf(Enum.java:236)
        at designstudent.combobutton$options.valueOf(combobutton.java:30)
        at designstudent.combobutton.<init>(combobutton.java:37)
        at designstudent.combobutton$1.run(combobutton.java:122)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:660)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
BUILD SUCCESSFUL (total time: 1 second)
  • 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-05-27T23:11:32+00:00Added an answer on May 27, 2026 at 11:11 pm

    This problem has nothing to do with the database. Your problem is right here:

     String PoptnStr; 
     options val = options.valueOf(PoptnStr); 
    

    You create your String which is initialized to null, then immediately use it, so you’ve written options.valueOf(null);

    Also, by convention, class names should start with capital letters (i.e. options should be Options) and instance variable names should be camel case (i.e. PoptnStr should be poptnStr).

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

Sidebar

Related Questions

I use the following code for retrieve the data from mysql Student data Base.It
I currently use the following code to retrieve and decompress string data from Amazon
I have tried to use the following code to retrieve the data from the
I use the following code for retrieve the data from my Sql DB.retrieve StudName
I am trying to figure out how to retrieve data from a MySQL database
I use the following code to retrieve image from the phone or SDCard and
To retrieve data from ActiveDirectory I used the following code: SPSecurity.RunWithElevatedPrivileges(delegate() ( var currentDirectory
I use the following code for retrieve the data into combobox. How to change
Currently I use the following code to retrieve the IP address of the local
I use the following code: - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSHTTPURLResponse *)response {

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.