after the last input when I press enter for the program to insert the five details I receive the following error and I cannot figure where I am going wron lease help!
"Exception in thread "main" java.lang.NullPointerException
at matchBeans.Results.entryMatchResults(Results.java: 113)
at matchBeans.Results.displayMenu(Results.java:51)
at matchBeans.Results.main(Results.java:17)"
================================================== =========
BELOW IS PART OF METHOD (CODE)
Expand|Select|Wrap|Line Numbers
- @SuppressWarnings("null")
- public static void entryMatchResults(Scanner input)
- { Statement statement=null;
- Connection link;
- Scanner input1 = new Scanner(System.in);
- int matchID;
- String opponents;
- String homeOraway;
- int clubScore,opponentsScore;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- DriverManager.getConnection(
- "jdbc:odbc:ClubData","","");
- }
- catch(ClassNotFoundException cnfEx)
- {
- System.out.println("* Unable to load driver! *");
- System.exit(1);
- }
- catch(SQLException sqlEx)
- {
- System.out.println(
- "* Cannot connect to database! *");
- System.exit(1);
- }
- System.out.print(
- "\nEnter new match ID: ");
- matchID = input1.nextInt();
- System.out.print("\nEnter new first team name: ");
- opponents = input1.nextLine();
- input1.nextLine();
- System.out.print("\nEnter new second team name(s): ");
- homeOraway = input1.nextLine();
- System.out.print("\nEnter first team score: ");
- clubScore = input1.nextInt();
- System.out.print("\nEnter second team score: ");
- opponentsScore = input1.nextInt();
- try
- {
- String insert = "INSERT INTO Results VALUES("
- + matchID + ",'"
- + opponents + "','"
- + homeOraway + "',"
- + clubScore + "'"
- + opponentsScore +",)'";
- statement.executeUpdate(insert);
- System.out.println("\nContents have been inserted:\n");
- }
- catch(SQLException sqlEx)
- {
- System.out.println("* Cannot insert match details ! *");
- sqlEx.printStackTrace();
- System.exit(0);
- }
- closeDown();
- }
- private static void closeDown()
- {
- System.out.println("Cannot disconnect from data base:");
- }