Skip to content
Snippets Groups Projects
Commit 81407cc8 authored by Kozusznik Jan's avatar Kozusznik Jan
Browse files

init

parents
Branches master
No related merge requests found
Pipeline #973 failed with stages
in 0 seconds
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>koz01.java2</groupId>
<artifactId>derbydialect-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.version>3.10.1</maven.compiler.version>
<javafx.version>17.0.6</javafx.version>
<junit.version>5.9.2</junit.version>
<log4j.version>2.20.0</log4j.version>
<lombok.version>1.18.26</lombok.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>koz01.java2</groupId>
<artifactId>dialects-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
package koz01.java2.dialects_lib.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Objects;
import koz01.java2.dialects_lib.JDBCDialect;
public class DerbyJDBCDialect implements JDBCDialect{
@Override
public String getDriverClazzName() {
return "org.apache.derby.jdbc.EmbeddedDriver";
}
@Override
public Connection getConnection(String dbName) throws SQLException {
return DriverManager.getConnection("jdbc:derby:" + dbName + ";create=true");
}
@Override
public String getCreateTable() {
return "CREATE TABLE person(id int GENERATED ALWAYS AS IDENTITY, first_name varchar(64), last_name varchar(64), email varchar(64))";
}
@Override
public void handleExceptionForCreation(SQLException e) {
//table already exist
if(Objects.equals(e.getSQLState(), "X0Y32")) {
return;
}
e.printStackTrace();
}
}
import koz01.java2.dialects_lib.JDBCDialect;
import koz01.java2.dialects_lib.impl.DerbyJDBCDialect;
module koz01.java2.derbydialect_lib {
requires koz01.java2.dialects_lib;
provides JDBCDialect with DerbyJDBCDialect;
}
\ No newline at end of file
<Configuration>
<Appenders>
<Console name="Console">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"></AppenderRef>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment