sqlite part 0

This commit is contained in:
Jannik 2020-01-05 00:04:22 +01:00
parent d3be609d16
commit 7bbf5eb963
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
3 changed files with 28 additions and 2 deletions

View File

@ -23,8 +23,10 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.hsqldb:hsqldb'
implementation 'org.xerial:sqlite-jdbc:3.28.0'
testCompile("org.springframework.boot:spring-boot-starter-test")
}

View File

@ -2,9 +2,11 @@ package org.hso.ecommerce.db;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
@ -16,11 +18,16 @@ public class CustomerConfig extends AbstractJdbcConfiguration {
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.sqlite.JDBC");
dataSource.setUrl("jdbc:sqlite:mydb.db");
return dataSource;
/* return new EmbeddedDatabaseBuilder()
.generateUniqueName(true)
.setType(EmbeddedDatabaseType.HSQL)
.addScript("classpath:db/customers.sql")
.build();
.build();*/
}
@Bean

View File

@ -0,0 +1,17 @@
package org.hso.ecommerce.db;
import org.hibernate.dialect.Dialect;
import java.sql.Types;
public class SQLiteDialect extends Dialect {
public SQLiteDialect() {
registerColumnType(Types.BIT, "integer");
registerColumnType(Types.TINYINT, "tinyint");
registerColumnType(Types.SMALLINT, "smallint");
registerColumnType(Types.INTEGER, "integer");
// other data types
}
}