2

I am trying to connect to an online database. Every now and then it gives me the following error:

Exception in thread "Timer" java.lang.NullPointerException: Cannot invoke "com.microsoft.sqlserver.jdbc.TDSReader.peekTokenType()" because "tdsReader" is null
    at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:61)
    at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:37)
    at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:26)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.processExecuteResults(SQLServerStatement.java:1279)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.processResponse(SQLServerStatement.java:774)
    at com.microsoft.sqlserver.jdbc.TDSCommand.close(IOBuffer.java:7264)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.discardLastExecutionResults(SQLServerStatement.java:143)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:214)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:693)
    at Interface.Player_One_Screen$1.run(Player_One_Screen.java:71)
    at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
    at java.base/java.util.TimerThread.run(Timer.java:506)

The only line referenced in my code is the following:

rs2 = statement.executeQuery("SELECT PlayerOne FROM tblTurn");

This line is part of a TimerTask that checks the player's turn in the online database at set intervals. There is no pattern to when this happens. I have absolutely no experience with this type of error.

NiNoes
  • 37
  • 6

1 Answers1

0

You may make calls to Logger objects in your application, which produce LogRecord instances, which are then given to Handler objects for processing. To control which LogRecords are handled, both the Logger and Handler classes employ recording levels and, optionally, logging filters. When the logging activities are finished, the Handler objects can publish the log data using Formatter objects.

Note: The java.util.logging framework writes its output to a file by default. For the context in which the JDBC driver is operating, this output log file must have write rights.

The sections that follow detail the various logging levels and categories that may be tracked, as well as how to enable tracing in your application.

Logging Levels:

Every log message has a logging level associated with it. The logging level, which is specified by the Level class in java.util.logging, defines the significance of the log message. Enabling logging at one level enables logging at all subsequent levels. This section discusses the logging levels for both public and internal logging categories. See the Logging Categories section of this article for additional information on the logging categories.

Logging Categories:

When you construct a Logger object, you must tell it which named item or category you want to collect log information from. The com.microsoft.sqlserver.jdbc driver package defines the following public logging categories, which are all supported by the JDBC driver.

As per the error, the SQLServerStatement.java needs to be modified.

  • You must enable logging programmatically to achieve the solution. The applications can set the logging level as FINE, FINER, and FINEST.

Here, are the reference which might help having dipper insights: Tracing driver operation and sql-docs/tracing-driver-operation.md at live · MicrosoftDocs/sql-docs · GitHub

IpsitaDash-MT
  • 1,326
  • 1
  • 3
  • 7