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.