Skip to content

Commit

Permalink
initial project setup. adds first notes on jdbc chapter. includes bui…
Browse files Browse the repository at this point in the history
…ld scripts and other config files
  • Loading branch information
dbubenheim committed May 2, 2021
0 parents commit c0ecbb3
Show file tree
Hide file tree
Showing 13 changed files with 570 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

66 changes: 66 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.DS_Store
.idea/
.idea/shelf
/confluence/target
/dependencies/repo
/android.tests.dependencies
/dependencies/android.tests.dependencies
/dist
/local
/gh-pages
/ideaSDK
/clionSDK
/android-studio/sdk
out/
/tmp
workspace.xml
*.versionsBackup
/idea/testData/debugger/tinyApp/classes*
/jps-plugin/testData/kannotator
/js/js.translator/testData/out/
/js/js.translator/testData/out-min/
/js/js.translator/testData/out-pir/
.gradle/
build/
!**/src/**/build
!**/test/**/build
*.iml
!**/testData/**/*.iml
.idea/libraries/Gradle*.xml
.idea/libraries/Maven*.xml
.idea/artifacts/PILL_*.xml
.idea/artifacts/KotlinPlugin.xml
.idea/modules
.idea/runConfigurations/JPS_*.xml
.idea/runConfigurations/PILL_*.xml
.idea/libraries
.idea/modules.xml
.idea/gradle.xml
.idea/compiler.xml
.idea/inspectionProfiles/profiles_settings.xml
.idea/.name
.idea/artifacts/dist_auto_*
.idea/artifacts/dist.xml
.idea/artifacts/ideaPlugin.xml
.idea/artifacts/kotlinc.xml
.idea/artifacts/kotlin_compiler_jar.xml
.idea/artifacts/kotlin_plugin_jar.xml
.idea/artifacts/kotlin_jps_plugin_jar.xml
.idea/artifacts/kotlin_daemon_client_jar.xml
.idea/artifacts/kotlin_imports_dumper_compiler_plugin_jar.xml
.idea/artifacts/kotlin_main_kts_jar.xml
.idea/artifacts/kotlin_compiler_client_embeddable_jar.xml
.idea/artifacts/kotlin_reflect_jar.xml
.idea/artifacts/kotlin_stdlib_js_ir_*
.idea/artifacts/kotlin_test_js_ir_*
.idea/artifacts/kotlin_stdlib_wasm_*
.idea/jarRepositories.xml
kotlin-ultimate/
node_modules/
.rpt2_cache/
libraries/tools/kotlin-test-js-runner/lib/
local.properties
buildSrcTmp/
distTmp/
outTmp/
lib/
38 changes: 38 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.7.1/userguide/building_java_projects.html
*/

plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
}

repositories {
// Use JCenter for resolving dependencies.
jcenter()
}

dependencies {
// Use JUnit Jupiter API for testing.
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")

// Use JUnit Jupiter Engine for testing.
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

// This dependency is used by the application.
implementation("com.google.guava:guava:29.0-jre")
}

application {
// Define the main class for the application.
mainClass.set("de.dbubenheim.learning.App")
}

tasks.test {
// Use junit platform for unit tests.
useJUnitPlatform()
}
14 changes: 14 additions & 0 deletions app/src/main/java/de/dbubenheim/learning/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package de.dbubenheim.learning;

public class App {
public String getGreeting() {
return "Hello World!";
}

public static void main(String[] args) {
System.out.println(new App().getGreeting());
}
}
61 changes: 61 additions & 0 deletions app/src/main/resources/00-exam-topics/00.exam-topics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 1Z0–819: Java SE 11 Developer

## Working with Java data types
- Use primitives and wrapper classes, including, operators, parentheses, type promotion and casting
- Handle text using String and StringBuilder classes
- Use local variable type inference, including as lambda parameters

## Controlling Program Flow
- Create and use loops, if/else, and switch statements

## Java Object-Oriented Approach
- Declare and instantiate Java objects including nested class objects, and explain objects’ lifecycles (including creation, dereferencing by reassignment, and garbage collection)
- Define and use fields and methods, including instance, static and overloaded methods
- Initialize objects, and their members using instance and static initialiser statements and constructors
- Understand variable scopes, apply encapsulation and make objects immutable
- Create and use subclasses and superclasses, including abstract classes
- Utilize polymorphism and casting to call methods, differentiate object type versus reference type
- Create and use interfaces, identify functional interfaces, and utilize private, static, and default methods
- Create and use enumerations

## Exception Handling
- Handle exceptions using try/catch/finally clauses, try-with-resource, and multi-catch statements
- Create and use custom exceptions

## Working with Arrays and Collections
- Use generics, including wildcards
- Use a Java array and List, Set, Map and Deque collections, including convenience methods
- Sort collections and arrays using Comparator and Comparable interfaces

## Working with Streams and Lambda expressions

- Implement functional interfaces using lambda expressions, including interfaces from the java.util.function package
- Use Java Streams to filter, transform and process data
- Perform decomposition and reduction, including grouping and partitioning on sequential and parallel streams

## Java Platform Module System
- Deploy and execute modular applications, including automatic modules
- Declare, use, and expose modules, including the use of services

## Concurrency

- Create worker threads using Runnable and Callable, and manage concurrency using an ExecutorService and java.util.concurrent API
- Develop thread-safe code, using different locking mechanisms and java.util.concurrent API

## Java I/O API
- Read and write console and file data using I/O Streams
- Implement serialization and deserialization techniques on Java objects
- Handle file system objects using java.nio.file API

## Secure Coding in Java SE Application
- Develop code that mitigates security threats such as denial of service, code injection, input validation and ensure data integrity
- Secure resource access including filesystems, manage policies and execute privileged code

## Database Applications with JDBC
- Connect to and perform database SQL operations, process query results using JDBC API

## Localization
- Implement Localization using Locale, resource bundles, and Java APIs to parse and format messages, dates, and numbers

## Annotations
- Create, apply, and process annotations
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# JDBC (Java Database Connectivity)

Provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java™ programming language.

## JDBC interfaces

- `java.sql.Driver`
- `java.sql.Connection`
- `java.sql.Statement`
- `java.sql.PreparedStatement`
- `java.sql.CallableStatement`
- `java.sql.ResultSet`
- `javax.sql.DataSource`

## JDBC urls

```
protocol:subprotocol://subname
```

```
jdbc:vendor://host:port/schema
```

### examples
```
jdbc:mysql://localhost:3306/myschema
jdbc:postgresql://localhost/myschema
jdbc:oracle:thin:@localhost:myschema
jdbc:derby:myschema
jdbc:h2:~/myschema
```

## connecting to a database

### Driver Manager
```java
Connection connection = DriverManager.getConnection("jdbc:derby:myschema")
// Connection connection = DriverManager.getConnection("jdbc:derby:myschema", "user", "password")
```

### Data Source

```java
Context context = new InitialContext();
DataSource dataSource = (DataSource) context.lookup("jdbc/billingDB");
Connection connection = dataSource.getConnection();
// Connection connection = dataSource.getConnection(user, password);
```


## try-with-resources

```java

try (Connection connection = DriverManager.getConnection("jdbc:derby:myschema")) {
Statement statement = connection.prepareStatement("SELECT * FROM table");
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
System.out.println(resultSet.getString("column"));
}
}
```


## `PreparedStatement`


## `CallableStatement`


## JDBC exceptions

- `java.sql.SQLException` and it's subclasses
14 changes: 14 additions & 0 deletions app/src/test/java/de/dbubenheim/learning/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package de.dbubenheim.learning;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class AppTest {
@Test void appHasAGreeting() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit c0ecbb3

Please sign in to comment.