-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completed error handling with default stop at 1000 errors
- Loading branch information
1 parent
8b70dfd
commit aa594ff
Showing
8 changed files
with
226 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/test/kotlin/com/github/dataanon/support/MoviesTableHavingGenreSize10.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.github.dataanon.support | ||
|
||
import com.github.dataanon.model.DbConfig | ||
import java.sql.Connection | ||
import java.sql.Date | ||
|
||
class MoviesTableHavingGenreSize10(dbConfig: DbConfig) { | ||
private val conn: Connection = dbConfig.connection() | ||
|
||
init { | ||
conn.createStatement().executeUpdate("DROP TABLE IF EXISTS MOVIES") | ||
val createMovieTable = "CREATE TABLE MOVIES( " + | ||
"MOVIE_ID INT, " + | ||
"TITLE VARCHAR2(255), " + | ||
"GENRE VARCHAR2(10), " + | ||
"RELEASE_DATE DATE, " + | ||
"PRIMARY KEY(MOVIE_ID) )" | ||
conn.createStatement().executeUpdate(createMovieTable) | ||
} | ||
|
||
fun insert(movieId: Int, title: String, genre: String?, releaseDate: Date): MoviesTableHavingGenreSize10 { | ||
val stmt = conn.prepareStatement("INSERT INTO MOVIES(MOVIE_ID,TITLE,GENRE,RELEASE_DATE) VALUES(?,?,?,?)") | ||
stmt.setInt(1, movieId) | ||
stmt.setString(2, title) | ||
stmt.setString(3, genre) | ||
stmt.setDate(4, releaseDate) | ||
stmt.executeUpdate() | ||
stmt.close() | ||
return this | ||
} | ||
|
||
fun findAll(): List<Map<String, Any?>> { | ||
val records = mutableListOf<Map<String, Any?>>() | ||
val rs = conn.createStatement().executeQuery("SELECT * FROM MOVIES") | ||
while (rs.next()) { | ||
val record = hashMapOf<String, Any?>() | ||
record["MOVIE_ID"] = rs.getInt("MOVIE_ID") | ||
record["TITLE"] = rs.getString("TITLE") | ||
record["GENRE"] = rs.getString("GENRE") | ||
record["RELEASE_DATE"] = rs.getDate("RELEASE_DATE") | ||
records.add(record) | ||
} | ||
rs.close() | ||
return records | ||
} | ||
|
||
fun close() { | ||
conn.close() | ||
} | ||
} |
Oops, something went wrong.