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 | 7 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  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 | 7 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 | 7 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]

    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