sqlite part 0
This commit is contained in:
parent
d3be609d16
commit
7bbf5eb963
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue