java.lang.NullPointerException

Spring JIRA | ismail altuntas | 3 years ago
  1. 0

    I have a custom Datasource implementation that not throw any exception when there is no DB connection. I am using this Datasource implementation with JdbcTemplate.java utility and when there is no connection JdbcTemplate throwing a NullPointerExeption. see the stack trace: {code} java.lang.NullPointerException at org.springframework.jdbc.core.JdbcTemplate$SimplePreparedStatementCreator.createPreparedStatement(JdbcTemplate.java:1375) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:580) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:685) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:693) {code} I think DataSourceUtils.getConnection() method should check the connection if it is null and then throw CannotGetJdbcConnectionException exception. So that appplication should check a meaningfull exception to take an action in this case. Similarly to above case when a transactional operation exist following exception is occured. In this case also CannotGetJdbcConnectionException should be occured ; {code} org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.lang.IllegalArgumentException: Connection must not be null at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:240) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127) {code} Thanks

    Spring JIRA | 3 years ago | ismail altuntas
    java.lang.NullPointerException
  2. 0

    I have a custom Datasource implementation that not throw any exception when there is no DB connection. I am using this Datasource implementation with JdbcTemplate.java utility and when there is no connection JdbcTemplate throwing a NullPointerExeption. see the stack trace: {code} java.lang.NullPointerException at org.springframework.jdbc.core.JdbcTemplate$SimplePreparedStatementCreator.createPreparedStatement(JdbcTemplate.java:1375) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:580) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:685) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:693) {code} I think DataSourceUtils.getConnection() method should check the connection if it is null and then throw CannotGetJdbcConnectionException exception. So that appplication should check a meaningfull exception to take an action in this case. Similarly to above case when a transactional operation exist following exception is occured. In this case also CannotGetJdbcConnectionException should be occured ; {code} org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.lang.IllegalArgumentException: Connection must not be null at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:240) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127) {code} Thanks

    Spring JIRA | 3 years ago | ismail altuntas
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.jdbc.core.JdbcTemplate$SimplePreparedStatementCreator.createPreparedStatement()
    2. Spring Framework
      JdbcTemplate.query
      1. org.springframework.jdbc.core.JdbcTemplate$SimplePreparedStatementCreator.createPreparedStatement(JdbcTemplate.java:1375)
      2. org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:580)
      3. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636)
      4. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665)
      5. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:685)
      6. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:693)
      6 frames