locked
java.lang.NullPointerException ::::buildParamTypeDefinitions(SQLServerPreparedStatement.java:243) RRS feed

  • Question

  • Hi Team,

    I am getting the below exception while executing an insert query to the database.

    This issue doesn't happen all the time. We see this problem only when there are lots of transactions being done.

    Can you please let me know as what could be the root cause of this issue.

    java.lang.NullPointerException
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildParamTypeDefinitions(SQLServerPreparedStatement.java:243)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildPreparedStrings(SQLServerPreparedStatement.java:219)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doPrepExec(SQLServerPreparedStatement.java:612)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:400)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314)

    Monday, November 24, 2014 6:48 PM

Answers

  • Hi somasekhar,

    >> This issue doesn't happen all the time. We see this problem only when there are lots of transactions being done.
    According to your description and based on my research, this error may happen when trying to execute the following code without achieving the connection to SQL Server successfully:
    ps = con.prepareStatement(sql);

    As you have mentioned above, this problem happens only when there are lots of transactions being done. So please go to check whether the value of the maximum pool size of the connection pool is appropriately set. Please make sure the value of max pool size is set to a value that lager than the number you need to connect to SQL Server simultaneously.

    If you have any question, please feel free to let me know.

    Regards,
    Jerry Li

    • Marked as answer by Donghui Li Tuesday, December 2, 2014 1:39 AM
    • Unmarked as answer by somasekhar T Wednesday, December 3, 2014 5:20 PM
    • Marked as answer by Donghui Li Tuesday, December 16, 2014 1:54 AM
    Wednesday, November 26, 2014 6:21 AM

All replies

  • Monday, November 24, 2014 7:08 PM
  • Hi,

    Thanks for the response.

    I have gone through the thread and found that the exception in that case is where preparedstatement is not declared. In our code, the exception is happening when I am trying to execute the query i.e., at executeUpdate method. Also, the same code in our application is invoked and it is working fine, but fails intermittently with the above exception. Please let me know.

    Tuesday, November 25, 2014 7:44 AM
  • Hi somasekhar,

    >> This issue doesn't happen all the time. We see this problem only when there are lots of transactions being done.
    According to your description and based on my research, this error may happen when trying to execute the following code without achieving the connection to SQL Server successfully:
    ps = con.prepareStatement(sql);

    As you have mentioned above, this problem happens only when there are lots of transactions being done. So please go to check whether the value of the maximum pool size of the connection pool is appropriately set. Please make sure the value of max pool size is set to a value that lager than the number you need to connect to SQL Server simultaneously.

    If you have any question, please feel free to let me know.

    Regards,
    Jerry Li

    • Marked as answer by Donghui Li Tuesday, December 2, 2014 1:39 AM
    • Unmarked as answer by somasekhar T Wednesday, December 3, 2014 5:20 PM
    • Marked as answer by Donghui Li Tuesday, December 16, 2014 1:54 AM
    Wednesday, November 26, 2014 6:21 AM
  • Hi Jerry,

    Thanks for the response.

    From the exception trace, it is clear that the exception is occuring when executeUpdate is invoked but not during con.prepareStatement(sql).

    Can you please confirm if you are saying that the con.prepareStatement is not having the connection established properly to sql server and while invoking executeUpdate it is giving an exception. Can you please confirm if the understanding is right.

    Regards,

    Somasekhar.

    Wednesday, December 3, 2014 5:19 PM
  • Can you please confirm if you are saying that the con.prepareStatement is not having the connection established properly to sql server and while invoking executeUpdate it is giving an exception. Can you please confirm if the understanding is right.

    Hi Somasekhar,

    Yes, I think that is the case based on the error message and your description.

    By the way, have you went to check whether the value of the maximum pool size of the connection pool is appropriately set? Please make sure the value of max pool size is set to a value that lager than the number you need to connect to SQL Server simultaneously.

    If you have any question, please feel free to let me know.

    Regards,
    Jerry Li


    Thursday, December 4, 2014 7:56 AM
  • Hi Somasekhar,

    I’m writing to follow up with you on this post. Was the problem resolved after performing our action plan steps?

    If you are satisfied with the solution, I’d like to mark this issue as "Answered". Please also feel free to unmark the issue, with any new findings or concerns you may have.  

    Thanks,
    Jerry Li

    Tuesday, December 16, 2014 1:54 AM