Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Added an example of batch processing of prepared statement. | c206f2899162396a7f391728db8be23031253454 | caubert | 2021-03-31 13:38:48 |
Fixed pb (CONSULTATION relation: justification, primary key and normal form) | 14aef6161421064f879c5fe803abb4836eebba0a | caubert | 2021-03-25 20:58:59 |
Fixed pb (CONSULTATION relation: justification, primary key and normal form) | be645c3e4215fd02ed089b843582d8c870525366 | caubert | 2021-03-25 20:55:34 |
Fixes in the DB app chapter. | 50082333323792958b213f9b0e5e7dc3a2ed47c5 | caubert | 2021-03-24 18:46:24 |
Fixed some include code. | 9caf6bc12caded947f222cb03fa0c1b10f2c8041 | caubert | 2021-03-24 13:11:20 |
Added question from quiz #3 | 7426197119517bff992e7753174de82ae3ff7ed7 | caubert | 2021-03-22 16:37:09 |
Added instructions in case the server time zone is off. | 6f845eee2eec6538a18e6e64fa5e140039aa4482 | caubert | 2021-03-22 14:32:00 |
Added a reference to UML. | 7b36cee0763b42c481474181423020cb600123fd | caubert | 2021-03-17 13:59:50 |
Some notes in DB applications added. | 3535d187737aea90413e73489729a4a64ce89f80 | caubert | 2021-03-17 13:55:48 |
Fixed typo | cfc6ac63d8ed0d0a2b9f4f530524d4723f5baae6 | caubert | 2021-03-12 18:36:32 |
fixed couple of typos. | 6191d6cc01638c07ab0b48a086718fc2440fa367 | caubert | 2021-03-12 18:31:47 |
Added quiz #2$ | ff134e831427d6e24603af76be52576928dae301 | caubert | 2021-03-01 19:51:12 |
Added missing file. | d7f2b8ceb14456db8ee2857fcd2b9445bcff1f95 | caubert | 2021-02-16 18:54:57 |
Added more complex queries and triggers for HW_Vaccine. | 1b133f143e9c6fec72271de28345df39689235f8 | caubert | 2021-02-09 20:23:30 |
Added project 1 and its solution. | 14f03a1733c084b26dbc72c009e2b7b832ed8643 | caubert | 2021-02-06 21:46:04 |
Added project 1 and its solution. | b7a31871ebccbf4caff81d9d57ed6847f4dc5543 | caubert | 2021-02-06 21:45:24 |
Added simple examples for SQL. | 4ea62f6930ff19bcff8d406d95c9cd84c0f0216d | caubert | 2021-02-02 22:24:41 |
Added first project. | e851058cc58a9d47ada9970f8b914e798c7d2ce7 | caubert | 2021-01-27 19:57:12 |
Few typos. | 45ba15cd03fab4388439b617c656f52b2ec96319 | caubert | 2021-01-26 20:08:24 |
Small fix in code. | 7860e391d0bbe82336b8f05585f846e829d181b1 | caubert | 2021-01-26 18:55:17 |
File | Lines added | Lines deleted |
---|---|---|
notes/code/java/BatchPreparedStatements.java | 40 | 0 |
notes/lectures_notes.md | 11 | 1 |
File notes/code/java/BatchPreparedStatements.java added (mode: 100644) (index 0000000..12cb00c) | |||
1 | // code/java/BatchPreparedStatements.java | ||
2 | |||
3 | // java.util.Scanner is an API to read from the keyboard. | ||
4 | import java.sql.*; | ||
5 | |||
6 | public class BatchPreparedStatements { | ||
7 | public static void main(String[] args) { | ||
8 | try (Connection conn = | ||
9 | DriverManager.getConnection( | ||
10 | "jdbc:mysql://localhost:3306/?user=testuser&password=password" | ||
11 | + "&allowMultiQueries=true"); | ||
12 | Statement stmt = | ||
13 | conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ) { | ||
14 | stmt.addBatch("DROP SCHEMA IF EXISTS HW_BATCH_PREPARED"); | ||
15 | stmt.addBatch("CREATE SCHEMA HW_BATCH_PREPARED"); | ||
16 | stmt.addBatch("USE HW_BATCH_PREPARED"); | ||
17 | stmt.addBatch("CREATE TABLE TEST(ID INT PRIMARY KEY)"); | ||
18 | stmt.executeBatch(); | ||
19 | |||
20 | // start snippet batchprepared | ||
21 | PreparedStatement ps = conn.prepareStatement("INSERT INTO TEST VALUES (?);"); | ||
22 | for (int i = 0; i < 10; i++) { | ||
23 | ps.setInt(1, i); | ||
24 | ps.addBatch(); | ||
25 | } | ||
26 | |||
27 | ps.executeBatch(); | ||
28 | // endsnippet batchprepared | ||
29 | |||
30 | // Note that there is no need to execute the clearBatch() method | ||
31 | // afterward, as the batch is automatically cleared. | ||
32 | // Cf. https://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#clearBatch-- | ||
33 | |||
34 | ps.executeBatch(); // Does nothing, the batch have been emptied. | ||
35 | |||
36 | } catch (SQLException ex) { | ||
37 | ex.printStackTrace(); | ||
38 | } | ||
39 | } | ||
40 | } |
File notes/lectures_notes.md changed (mode: 100644) (index 54f6de7..019a5e0) | |||
... | ... | A typical (meeting twice a week, ±17 weeks, ±30 classes) semester is divided a | |
128 | 128 | - Lecture 17--20: [Guidelines and Normal Form](#guidelines-and-normal-form) | - Lecture 17--20: [Guidelines and Normal Form](#guidelines-and-normal-form) |
129 | 129 | - Lecture 21--22: [Unified Modeling Language Diagram](#unified-modeling-language-diagrams) | - Lecture 21--22: [Unified Modeling Language Diagram](#unified-modeling-language-diagrams) |
130 | 130 | - Lecture 23--24: Review session and Exam #2 | - Lecture 23--24: Review session and Exam #2 |
131 | - Lecture 25--18: [Database Applications](#databases-applications) | ||
131 | - Lecture 25--28: [Database Applications](#databases-applications) | ||
132 | 132 | - Lecture 29--30: [Presentation of NoSQL](#presentation-of-nosql) | - Lecture 29--30: [Presentation of NoSQL](#presentation-of-nosql) |
133 | 133 | ||
134 | 134 | For information purposes, an indication like this: | For information purposes, an indication like this: |
... | ... | As an example of how to technically declare and use a procedure from an applicat | |
9020 | 9020 | ```{.java .numberLines .includeLink include=code/java/CallProcedure.java} | ```{.java .numberLines .includeLink include=code/java/CallProcedure.java} |
9021 | 9021 | ``` | ``` |
9022 | 9022 | ||
9023 | ## Making It Your Own | ||
9024 | |||
9025 | Now that you have reviewed some of the tools and options in the API, you can start programming and naviguating the [documentation](on your own). | ||
9026 | As an exercise, you can try to combine prepared statements and batch processing on your own. | ||
9027 | It is actually fairly immediate! | ||
9028 | |||
9029 | ```{.java .numberLines .includeLink include=code/java/BatchPreparedStatements.java snippet=batchprepared} | ||
9030 | ``` | ||
9031 | |||
9032 | |||
9023 | 9033 | ||
9024 | 9034 | ## Exercises {-} | ## Exercises {-} |
9025 | 9035 |