https://github.com/jbilander/mm-api
A RESTful web service with Jersey/JAX-RS on Java 9 packaged and deployed as a webapp (war-file) in Tomcat 9.
https://github.com/jbilander/mm-api
Last synced: 11 months ago
JSON representation
A RESTful web service with Jersey/JAX-RS on Java 9 packaged and deployed as a webapp (war-file) in Tomcat 9.
- Host: GitHub
- URL: https://github.com/jbilander/mm-api
- Owner: jbilander
- Created: 2018-03-23T09:20:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-10T05:40:32.000Z (about 8 years ago)
- Last Synced: 2025-03-31T11:14:01.735Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Technologies used in this project:
- Jersey 2.26/ JAX-RS 2.1
- Json/Jackson 2.26 (annotations)
- Java SDK 9
- Tomcat 9
- JNDI DataSource (Commons DBCP 2 Connection Pool in Tomcat 9)
- MariaDB Connector/J 2.2.3 jdbc-driver for MySQL
- Fast Socket-connection to MySQL (Unix-socket/Windows-Pipe), Requires App and Db on same machine!
- Pure JDBC with Prepared Statements and transaction-handling/rollbacks
- Simple logging with java.util.logging
- Maven 3
- Packaged with Maven 3 "package"-feature as a war-file
Caveats Java 9 SDK:
The java.xml.bind module is deprecated for removal in Java 9 (along with the other modules shared with Java EE) so expect these modules to not be included in the JDK some day.
To make the JAXB APIs available at runtime, specify the following VM option:
Windows, add this to bin/catalina.bat:
set JDK_JAVA_OPTIONS=--add-modules java.xml.bind
Linux, add this to bin/catalina.sh:
export JDK_JAVA_OPTIONS=--add-modules java.xml.bind
DataSource config added in Tomcats conf/context.xml-file:
Windows:
<Context>
<Resource name="jdbc/MyAtgDS" auth="Container" type="javax.sql.DataSource"
maxTotal="100" maxIdle="30" maxWaitMillis="10000" validationQuery="select 1"
username="my_user" password="my_password" driverClassName="org.mariadb.jdbc.Driver"
url="jdbc:mariadb://localhost/myatg?autoReconnect=true&pipe=C:\tmp\mysql.sock"/></Context>
Linux:
<Context>
<Resource name="jdbc/MyAtgDS" auth="Container" type="javax.sql.DataSource"
maxTotal="100" maxIdle="30" maxWaitMillis="10000" validationQuery="select 1"
username="my_user" password="my_password" driverClassName="org.mariadb.jdbc.Driver"
url="jdbc:mariadb://localhost/myatg?autoReconnect=true&localSocket=/var/run/mysqld/mysqld.sock"/>
</Context>
Connection to database in code through DataSource:
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/MyAtgDS");
Connection conn = ds.getConnection();