Eclipseでとあるプロジェクトをインポートして、Javaのコードを変更。(Windowsで操作)
そして、そのファイルを保存しようとしたら、「問題が発生 Negative time」のダイアログが表示。
何が問題かわからず、ググってみる。
以下の情報が見つかった。
Eclipse: can't save file - 'negative time' error
Eclipseでとあるプロジェクトをインポートして、Javaのコードを変更。(Windowsで操作)
そして、そのファイルを保存しようとしたら、「問題が発生 Negative time」のダイアログが表示。
何が問題かわからず、ググってみる。
以下の情報が見つかった。
Eclipse: can't save file - 'negative time' error
Javaでシステム開発するときに、他の人がデータベースの環境構築をする場合、データベースまわりのロジックの動作確認しつつ、開発を進めたいので、データベースはAccessのmdbで代替して開発している、というかしていた。
だって、mdbを新規作成して、デザインビューでテーブルの定義をするだけなので、楽だから。
で、久しぶりにやってみたら動かない。
jdbcodbcドライバーをロードするところで、Exceptionが発生している。
jdbcodbcドライバーをロードする箇所
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); return null; }Exceptionが発生!!
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264)どうしてだろう、と思い、調査してみると、こちらのサイトを発見。
// https://mvnrepository.com/artifact/net.sf.ucanaccess/ucanaccess compile group: 'net.sf.ucanaccess', name: 'ucanaccess', version: '5.0.0'そして、次のようにmdbファイルのパスを引数にして、コネクションを取得してデータベースアクセスできる。
Connection conn = null; try { conn = DriverManager.getConnection("jdbc:ucanaccess://D:/dbarea/db.mdb"); } catch (SQLException e) { e.printStackTrace(); }
compile("org.springframework.boot:spring-boot-devtools")
buildscript { ext { springBootVersion = '1.5.13.BUILD-SNAPSHOT' } repositories { mavenCentral() maven { url "https://repo.spring.io/snapshot" } maven { url "https://repo.spring.io/milestone" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() maven { url "https://repo.spring.io/snapshot" } maven { url "https://repo.spring.io/milestone" } } dependencies { compile('org.springframework.boot:spring-boot-starter-thymeleaf') { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } compile('org.springframework.boot:spring-boot-starter-log4j2') testCompile('org.springframework.boot:spring-boot-starter-test') } ext['thymeleaf.version'] = '3.0.9.RELEASE' ext['thymeleaf-layout-dialect.version'] = '2.3.0'
package com.example.hoge; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; @RestController public class HogeController { private static final Logger logger = LoggerFactory.getLogger(HogeController.class); @RequestMapping("/") public ModelAndView index(ModelAndView mav) { logger.info("#index START"); mav.setViewName("index"); return mav; } }
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"> <head> <title layout:title-pattern="$LAYOUT_TITLE - $CONTENT_TITLE">My website</title> <meta charset="UTF-8" /> </head> <body> <header layout:replace="~{layout/header::header}"></header> <article layout:fragment="content" style="background-color: lightpink;"></article> <footer layout:replace="~{layout/footer::footer}"></footer> </body> </html>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> <body> <header id="global-header" layout:fragment="header" style="background-color: beige;"> <p class="text-center">This is header</p> </header> </body> </html>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> <body> <footer id="global-footer" layout:fragment="footer" style="background-color: aqua;"> <p class="text-center">This is footer</p> </footer> </body> </html>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/layout}"> <head> <title>INDEX PAGE</title> </head> <body> <div layout:fragment="content" class="text-center"> <p style="height: 150px;">This is index page.</p> </div> </body> </html>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My website - INDEX PAGE</title> <meta charset="UTF-8" /> </head> <body> <header id="global-header" style="background-color: beige;"> <p class="text-center">This is header</p> </header> <div style="background-color: lightpink;" class="text-center"> <p style="height: 150px;">This is index page.</p> </div> <footer id="global-footer" style="background-color: aqua;"> <p class="text-center">This is footer</p> </footer> </body> </html>
buildscript { ext { springBootVersion = '1.5.13.BUILD-SNAPSHOT' } repositories { mavenCentral() maven { url "https://repo.spring.io/snapshot" } maven { url "https://repo.spring.io/milestone" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() maven { url "https://repo.spring.io/snapshot" } maven { url "https://repo.spring.io/milestone" } } dependencies { compile('org.springframework.boot:spring-boot-starter-web') { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } compile('org.springframework.boot:spring-boot-starter-log4j2') testCompile('org.springframework.boot:spring-boot-starter-test') }
<?xml version="1.0" encoding="UTF-8"?> <configuration status="OFF"> <Properties> <Property name="app_name">hoge</Property> <Property name="date">%d{yyyy-MM-dd HH:mm:ss.SSS}</Property> <Property name="daily_log">logs/app_${app_name}_%d{yyyy-MM-dd}.log</Property> <Property name="monthly_log">logs/app_monthly_${app_name}_%d{yyyy-MM}.log</Property> <Property name="error_daily_log">logs/app_error_${app_name}_%d{yyyy-MM-dd}.log</Property> </Properties> <appenders> <Console name="Console" target="SYSTEM_OUT" > <PatternLayout pattern="${date}, [${app_name}], [ %-5level ], %logger{10}, %msg %n" /> </Console> <RollingFile name="File" fileName="logs/app.log" filePattern="${daily_log}.gz" > <PatternLayout pattern="${date}, [${app_name}], [ %-5level ], %logger{10}, %msg %n" /> <Policies> <TimeBasedTriggeringPolicy /> </Policies> </RollingFile> <RollingFile name="ErrorFile" fileName="logs/app_error.log" filePattern="${error_daily_log}.gz" > <RegexFilter regex="\[ ERROR \]" /> <PatternLayout pattern="${date}, [${app_name}], [ %-5level ], %logger{10}, %msg %n" /> <Policies> <TimeBasedTriggeringPolicy /> </Policies> </RollingFile> <RollingFile name="MonthlyFile" fileName="logs/app_monthly.log" filePattern="${monthly_log}.gz" > <PatternLayout pattern="${date}, [${app_name}], [ %-5level ], %logger{10}, %msg %n" /> <Policies> <TimeBasedTriggeringPolicy /> </Policies> </RollingFile> </appenders> <loggers> <root level="info"> <appender-ref ref="Console" /> <appender-ref ref="File" /> <appender-ref ref="MonthlyFile" /> <appender-ref ref="ErrorFile" /> </root> </loggers> </configuration>
package com.example.hoge; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HogeController { private static final Logger logger = LoggerFactory.getLogger(HogeController.class); @RequestMapping("/") public String index() { logger.info("#index START"); return "Hello World."; } }
package com.example.hoge; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HogeController { @RequestMapping("/") public String index() { return "Hello World."; } }