Skip to content

Commit

Permalink
Merge pull request #49 from geranazavr555/master
Browse files Browse the repository at this point in the history
bloggy: use MariaDB connector, minor changes
  • Loading branch information
MikeMirzayanov authored Jul 5, 2023
2 parents 84e1e49 + 8f0bb9d commit 436f96d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion code/src/main/java/org/nocturne/template/impl/Less.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Less {
private static File tmpDir;

@SuppressWarnings("ResultOfMethodCallIgnored")
public synchronized static String compile(@Nonnull Object source, @Nonnull String lessCode, @Nullable File commonsFile) throws IOException {
public static synchronized String compile(@Nonnull Object source, @Nonnull String lessCode, @Nullable File commonsFile) throws IOException {
long commonsFileLastModified = commonsFile == null ? 0 : commonsFile.lastModified();
long commonsFileLength = commonsFile == null ? 0 : commonsFile.length();
String cacheKey = getName(source).trim() + "_" + commonsFileLastModified + "_" + commonsFileLength + "_" + hash(lessCode);
Expand Down
11 changes: 3 additions & 8 deletions samples/bloggy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,15 @@
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.1.4</version>
</dependency>
<dependency>
<groupId>com.codeforces</groupId>
<artifactId>commons</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>

<build>
Expand Down
4 changes: 2 additions & 2 deletions samples/bloggy/profile.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ logging.path=${development.home}/bloggy.log
timezone=Europe/Moscow
debug.static-src-path=${development.home}/src/main/webapp

database.url=jdbc:mysql://localhost/bloggy?useUnicode=true&characterSetResults=UTF-8&characterEncoding=UTF-8&serverTimezone=${timezone}
database.url=jdbc:mariadb://localhost/bloggy?useUnicode=true&characterSetResults=UTF-8&characterEncoding=UTF-8&serverTimezone=${timezone}
database.user=mysql
database.password=29970161bba289cf
database.password=???
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/
package bloggy.database;

import com.mysql.cj.jdbc.MysqlDataSource;
import org.apache.log4j.Logger;
import bloggy.exception.ApplicationException;
import org.mariadb.jdbc.MariaDbDataSource;

import javax.annotation.Nonnull;
import javax.sql.DataSource;
Expand Down Expand Up @@ -37,10 +37,14 @@ private static class DataSourceHolder {
private static final DataSource INSTANCE;

static {
MysqlDataSource instance = new MysqlDataSource();
instance.setUrl(PROPERTIES.getProperty("database.url"));
instance.setUser(PROPERTIES.getProperty("database.user"));
instance.setPassword(PROPERTIES.getProperty("database.password"));
MariaDbDataSource instance = new MariaDbDataSource();
try {
instance.setUrl(PROPERTIES.getProperty("database.url"));
instance.setUser(PROPERTIES.getProperty("database.user"));
instance.setPassword(PROPERTIES.getProperty("database.password"));
} catch (SQLException e) {
throw new ApplicationException("Can't initialize database connection", e);
}

try (Connection ignored = instance.getConnection()) {
logger.info("Database has been initialized, test database connection is OK.");
Expand Down
2 changes: 1 addition & 1 deletion samples/bloggy/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
log4j.rootCategory=INFO,log_file
log4j.rootCategory=INFO,stdout,log_file
log4j.logger.bloggy=INFO

log4j.appender.stdout.Threshold=INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</main>
</div>
<footer>
<a href="<@link name="IndexPage"/>">Bloggy</a> &copy; 2009-2019 by Mike Mirzayanov
<a href="<@link name="IndexPage"/>">Bloggy</a> &copy; 2009-2023 by Mike Mirzayanov
<div class="time">${now?string('yyyy-MM-dd HH:mm:ss')}</div>
</footer>
<script>
Expand Down

0 comments on commit 436f96d

Please sign in to comment.