1

I want to implement oauth2 authorization service using JdbcTemplate with Spring authorization server. I need to pre-initialize some database table for the Jdbc in order to create an authorization service. I looked through the example that they provided. They use EmbededDatabase and run the provided script like this.

    @Bean
    public EmbeddedDatabase embeddedDatabase() {
        // @formatter:off
        return new EmbeddedDatabaseBuilder()
                .generateUniqueName(true)
                .setType(EmbeddedDatabaseType.H2)
                .setScriptEncoding("UTF-8")
                .addScript("org/springframework/security/oauth2/server/authorization/oauth2-authorization-schema.sql")
                .addScript("org/springframework/security/oauth2/server/authorization/oauth2-authorization-consent-schema.sql")
                .addScript("org/springframework/security/oauth2/server/authorization/client/oauth2-registered-client-schema.sql")
                .build();
        // @formatter:on
    }

but I want to be able to pre-initialize script like this on existing database that I have. how can I do that? I have my database at localhost:3306 with username root and password very_secure.

Patrick
  • 734
  • 11
  • 26
  • Does this answer your question? [How to run SQL scripts and get data on application startup?](https://stackoverflow.com/questions/39280340/how-to-run-sql-scripts-and-get-data-on-application-startup) – Markus Dec 15 '22 at 16:11

0 Answers0