org.springframework.dao.DataAccessResourceFailureException: Failed to populate database; nested exception is java.sql.SQLException: Unexpected token INTOUSERS, requires INTO in statement [INSERT INTOusers]

Spring JIRA | Sam Brannen | 6 years ago
  1. 0

    h4. Status Quo The following lines from an SQL script worked with the {{EmbeddedDatabaseBuilder}} until I updated to the latest nightly snapshot ({{org.springframework.jdbc-3.0.4.BUILD-20100810.004442-53}}). {code:title=No longer working} INSERT INTO users(email_address, password, first_name, last_name, roles) values('sam.brannen@example.com', '$pr!ng', 'Sam', 'Brannen', 'ROLE_USER,ROLE_ADMIN'); {code} Execution of this script results in the following stacktrace: {code:title=Stacktrace} org.springframework.dao.DataAccessResourceFailureException: Failed to populate database; nested exception is java.sql.SQLException: Unexpected token INTOUSERS, requires INTO in statement [INSERT INTOusers] at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.populateDatabase(EmbeddedDatabaseFactory.java:158) at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.initDatabase(EmbeddedDatabaseFactory.java:138) at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.getDatabase(EmbeddedDatabaseFactory.java:114) at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder.build(EmbeddedDatabaseBuilder.java:112) {code} Removing the newline between {{INTO}} and {{users}} (as in the following script) works. Thus, recent changes (from 3.0.3 - 3.0.4) now swallow {{\n}} in SQL scripts, effectively concatenating adjacent lines. {code:title=Working} INSERT INTO users(email_address, password, first_name, last_name, roles) values('sam.brannen@example.com', '$pr!ng', 'Sam', 'Brannen', 'ROLE_USER,ROLE_ADMIN'); {code} h4. Proposed Solution {{ResourceDatabasePopulator}} should be modified to properly interpret _empty lines_ in contrast to simply swallowing all {{\n}} characters.

    Spring JIRA | 6 years ago | Sam Brannen
    org.springframework.dao.DataAccessResourceFailureException: Failed to populate database; nested exception is java.sql.SQLException: Unexpected token INTOUSERS, requires INTO in statement [INSERT INTOusers]
  2. 0

    h4. Status Quo The following lines from an SQL script worked with the {{EmbeddedDatabaseBuilder}} until I updated to the latest nightly snapshot ({{org.springframework.jdbc-3.0.4.BUILD-20100810.004442-53}}). {code:title=No longer working} INSERT INTO users(email_address, password, first_name, last_name, roles) values('sam.brannen@example.com', '$pr!ng', 'Sam', 'Brannen', 'ROLE_USER,ROLE_ADMIN'); {code} Execution of this script results in the following stacktrace: {code:title=Stacktrace} org.springframework.dao.DataAccessResourceFailureException: Failed to populate database; nested exception is java.sql.SQLException: Unexpected token INTOUSERS, requires INTO in statement [INSERT INTOusers] at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.populateDatabase(EmbeddedDatabaseFactory.java:158) at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.initDatabase(EmbeddedDatabaseFactory.java:138) at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.getDatabase(EmbeddedDatabaseFactory.java:114) at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder.build(EmbeddedDatabaseBuilder.java:112) {code} Removing the newline between {{INTO}} and {{users}} (as in the following script) works. Thus, recent changes (from 3.0.3 - 3.0.4) now swallow {{\n}} in SQL scripts, effectively concatenating adjacent lines. {code:title=Working} INSERT INTO users(email_address, password, first_name, last_name, roles) values('sam.brannen@example.com', '$pr!ng', 'Sam', 'Brannen', 'ROLE_USER,ROLE_ADMIN'); {code} h4. Proposed Solution {{ResourceDatabasePopulator}} should be modified to properly interpret _empty lines_ in contrast to simply swallowing all {{\n}} characters.

    Spring JIRA | 6 years ago | Sam Brannen
    org.springframework.dao.DataAccessResourceFailureException: Failed to populate database; nested exception is java.sql.SQLException: Unexpected token INTOUSERS, requires INTO in statement [INSERT INTOusers]
  3. 0

    Trying to configure Spring Batch Job Repository - Spring Forum

    spring.io | 6 months ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.datasource.init.DataSourceInitializer#0': Invocation of init method failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: Failed to populate database; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [org/springframework/batch/core/schema-postgresql.sql]: CREATE TABLE BATCH_JOB_INSTANCE ( JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY , VERSION BIGINT , JOB_NAME VARCHAR(100) NOT NULL, JOB_KEY VARCHAR(32) NOT NULL, constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY) )
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    map address problem

    GitHub | 1 month ago | rut78HR
    org.springframework.dao.DataAccessResourceFailureException: StatementCallback; SQL [INSERT INTO httpdata SELECT * FROM httpdata_ext_90f5e4e4_d363_4ba2_aa01_2f55b73f7cf7]; ERROR: connection with gpfdist failed for gpfdist://10.36.0.27:8000/data. effective url: http://10.36.0.27:8000/data. error code = 110 (Connection timed out) (seg0 slice1 dbslave01:40000 pid=28847); nested exception is org.postgresql.util.PSQLException: ERROR: connection with gpfdist failed for gpfdist://10.36.0.27:8000/data. effective url: http://10.36.0.27:8000/data. error code = 110 (Connection timed out) (seg0 slice1 dbslave01:40000 pid=28847)
  6. 0

    Using a plain DefaultDirContextValidator results in errors, with both Active Directory and Sun Directory Server. As soon as a valid base DN is set it works as expected. First a warning is logged: 14:05:50,355 WARN [DefaultDirContextValidator] DirContext 'javax.naming.ldap.InitialLdapContext@799f9a' failed validation with an exception. javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001A8, problem 2001 (NO_OBJECT), data 0, best match of: '' ]; remaining name '' at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3010) at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2931) at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2737) at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1808) at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1731) at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:321) at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:248) at org.springframework.ldap.pool.validation.DefaultDirContextValidator.validateDirContext(DefaultDirContextValidator.java:154) at org.springframework.ldap.pool.factory.DirContextPoolableObjectFactory.validateObject(DirContextPoolableObjectFactory.java:169) at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1035) at org.springframework.ldap.pool.factory.PoolingContextSource.getContext(PoolingContextSource.java:394) at org.springframework.ldap.pool.factory.PoolingContextSource.getReadOnlyContext(PoolingContextSource.java:374) at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:770) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:897) [...] then an error: 14:05:50,358 ERROR [SequentialChannelRunner] Channel run error! Channel: channel1 org.springframework.dao.DataAccessResourceFailureException: Failed to borrow DirContext from pool.; nested exception is java.util.NoSuchElementException: Could not create a validated object at org.springframework.ldap.pool.factory.PoolingContextSource.getContext(PoolingContextSource.java:397) at org.springframework.ldap.pool.factory.PoolingContextSource.getReadOnlyContext(PoolingContextSource.java:374) at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:770) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:897) [...] Caused by: java.util.NoSuchElementException: Could not create a validated object at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1049) at org.springframework.ldap.pool.factory.PoolingContextSource.getContext(PoolingContextSource.java:394) ... 9 more

    Spring JIRA | 8 years ago | Marius Scurtescu
    org.springframework.dao.DataAccessResourceFailureException: Failed to borrow DirContext from pool.; nested exception is java.util.NoSuchElementException: Could not create a validated object

    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. org.springframework.dao.DataAccessResourceFailureException

      Failed to populate database; nested exception is java.sql.SQLException: Unexpected token INTOUSERS, requires INTO in statement [INSERT INTOusers]

      at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.populateDatabase()
    2. org.springframework.jdbc
      EmbeddedDatabaseBuilder.build
      1. org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.populateDatabase(EmbeddedDatabaseFactory.java:158)
      2. org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.initDatabase(EmbeddedDatabaseFactory.java:138)
      3. org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.getDatabase(EmbeddedDatabaseFactory.java:114)
      4. org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder.build(EmbeddedDatabaseBuilder.java:112)
      4 frames