简体   繁体   中英

EmbeddedDatabaseBuilder & org.h2.jdbc.JdbcSQLException: Wrong user name or password

Spring Boot 1.1.5.RELEASE

public class DataAccessTests
{
    private EmbeddedDatabase db;

    @Before
    public void setUp()
    {
        EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
        db = builder.setType(H2).addDefaultScripts().build();
    }

    @Test
    public void testDataAccess() {
        JdbcTemplate template = new JdbcTemplate(db);
        int r = template.queryForObject("select 1", Integer.class);
        assertEquals(r, 1);
    }

    @After
    public void tearDown() {
        db.shutdown();
    }
}

Exception

org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-181]

Where I make a mistake?

I'm sorry for my mistake. When I wrote a demo application for this error I found a solution. The problem was that the settings were taken from my application rather than the default. After I commented out @SpringApplicationConfiguration(classes = App.class) everything works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM