List of commits:
Subject Hash Author Date (UTC)
Worked on procedure example from java 998ea14119a5a3f88efc4b0a126177e85151e43d aubert@math.cnrs.fr 2020-12-01 15:06:47
Brief example of calling a procedure from a program. 1054c9d5c83fb956bdd0b8d884d5ce2c8a9a640e aubert@math.cnrs.fr 2020-11-30 19:00:45
Added solution to second exam d8f62ded96991885a96d561db587988d453a28c8 aubert@math.cnrs.fr 2020-11-05 20:35:50
Quick fix on testing semicolons. 7f48d88d2ed69213d803a7736df3d50330cfecd1 aubert@math.cnrs.fr 2020-11-03 14:14:06
Added simple example to test if semicolon are important in SQL querries. 98097fb11558c08bad630fb3351f99ceb6777de7 aubert@math.cnrs.fr 2020-11-03 14:11:22
Updated spots to https. a8daf1768395aa296bf0dd05783dd53c757d5d19 aubert@math.cnrs.fr 2020-10-05 16:18:44
Adding quiz #2 98e0ae5b8ce766524f60c91adb1040235e1bbf31 aubert@math.cnrs.fr 2020-10-02 19:00:15
Added exam 1 e2f62ae4bf26fcc4b86e8665060ccf3918e7abeb aubert@math.cnrs.fr 2020-09-24 12:51:36
worked on solution to first exam. b13ad99dd895f124df1b642fd990071fc09db294 aubert@math.cnrs.fr 2020-09-23 17:44:01
Added solution to first problem. 0948cee47ed78dc115fd69c7bcf96a312dd3162f aubert@math.cnrs.fr 2020-09-18 21:43:00
Added solution to problem 2 of Exam #1. 7ad20b3c0025a4de3fa00729de570c6fe9176773 aubert@math.cnrs.fr 2020-09-18 21:34:19
Added solution to project 1. de427d78745593ab53dc70e7129b67fee1d4489c aubert@math.cnrs.fr 2020-09-10 19:04:45
Added example for MAX and NULL values. b82a496a5ffbcecaf2c5851f18d1b08ce8732623 aubert@math.cnrs.fr 2020-09-10 13:14:13
Changed SQL code formatting. 6c3cad5a2545f46ab113f7df7a83457857d82ed8 aubert@math.cnrs.fr 2020-09-09 17:04:55
Cleaned code. 5bdb4faed3a83b81257734f1e1aced2890783f04 aubert@math.cnrs.fr 2020-09-03 21:35:41
Added the first project. 564a02887933f2395bc40d7d8a10833f657659fd aubert@math.cnrs.fr 2020-08-28 22:34:08
Week 2 edits, added quiz #1, couple of fixes, replaced single quote with double quotes. 3c9942731678900122088356db3a2cbabd99b9be aubert@math.cnrs.fr 2020-08-27 19:00:13
Added ressource for makefile. 7696c44bca707646530a7dbb71bf2e05badaa306 aubert@math.cnrs.fr 2020-08-03 16:00:23
Crystal's final edits. 714e3030423a836c4ba07890f9aa5e45f58ad15a aubert@math.cnrs.fr 2020-05-21 17:43:26
Converted an image into a figure (Movie example). c55e61ed5d11631e908d99b14ef10a0a0247bda0 aubert@math.cnrs.fr 2020-05-20 20:58:41
Commit 998ea14119a5a3f88efc4b0a126177e85151e43d - Worked on procedure example from java
Author: aubert@math.cnrs.fr
Author date (UTC): 2020-12-01 15:06
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2020-12-01 15:06
Parent(s): 1054c9d5c83fb956bdd0b8d884d5ce2c8a9a640e
Signer:
Signing key:
Signing status: N
Tree: 075ed59e9764a38b39e02e7c64048a5893ddd637
File Lines added Lines deleted
notes/code/java/CallProcedure.java 42 22
notes/code/java/TestingSemicolon.java 1 1
File notes/code/java/CallProcedure.java changed (mode: 100644) (index d772f1d..9526ec0)
... ... import java.sql.*;
4 4
5 5 public class CallProcedure { public class CallProcedure {
6 6 public static void main(String[] args) { public static void main(String[] args) {
7 try (
8 Connection conn =
7 try (Connection conn =
9 8 DriverManager.getConnection( DriverManager.getConnection(
10 9 "jdbc:mysql://localhost:3306/HW_CALL_TEST" "jdbc:mysql://localhost:3306/HW_CALL_TEST"
11 10 + "?user=testuser" + "?user=testuser"
 
... ... public class CallProcedure {
14 13 + "&createDatabaseIfNotExist=true" + "&createDatabaseIfNotExist=true"
15 14 + "&useSSL=true"); + "&useSSL=true");
16 15 Statement stmt = conn.createStatement(); ) { Statement stmt = conn.createStatement(); ) {
17 stmt.execute(
18 "DROP SCHEMA IF EXISTS HW_CALL_TEST;" + "CREATE SCHEMA HW_CALL_TEST;" + "USE HW_CALL_TEST;");
19
20 16 stmt.execute( stmt.execute(
21 "CREATE TABLE Test1 ("
22 + "A VARCHAR(25) PRIMARY KEY, "
23 + "B INTEGER);");
17 "DROP SCHEMA IF EXISTS HW_CALL_TEST;"
18 + "CREATE SCHEMA HW_CALL_TEST;"
19 + "USE HW_CALL_TEST;");
20
21 stmt.execute("CREATE TABLE Test1 (" + "A INT PRIMARY KEY);");
24 22
25 stmt.execute("INSERT INTO Test1 VALUES ('Bob', 1), ('Crystal', 2), ('Jack', 1);");
23 stmt.execute("INSERT INTO Test1 VALUES (1), (2), (3);");
26 24 // To create a procedure, we don't need to change the delimiter! // To create a procedure, we don't need to change the delimiter!
27 25 // Cf. https://stackoverflow.com/a/5314879/ for instance. // Cf. https://stackoverflow.com/a/5314879/ for instance.
28 stmt.execute(" CREATE PROCEDURE List () "
29 + " BEGIN "
30 + " SELECT * "
31 + " FROM Test1; "
32 + " END; ");
33 // We create a CallabaleStatement object
34 // https://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html
35 // that extends PreparedStatements and allow to call procedures.
36 CallableStatement cs = conn.prepareCall("{call List}");
37 ResultSet rset = cs.executeQuery();
38 while(rset.next()){
39 System.out.println("The value of A is " + rset.getString("A") + " and the value of B is " + rset.getInt("B") + ".");
40 }
26 stmt.execute(
27 " CREATE PROCEDURE List () " + " BEGIN " + " SELECT * " + " FROM Test1; " + " END; ");
28 // We create a CallabaleStatement object
29 // https://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html
30 // that extends PreparedStatements and allow to call procedures.
31 CallableStatement cs = conn.prepareCall("CALL List()");
32 ResultSet rset = cs.executeQuery();
33 while (rset.next()) {
34 System.out.println("The value of A is " + rset.getInt("A") + ".");
35 }
36
37 // Second example of procedure, with arguments
38 stmt.execute(
39 " CREATE PROCEDURE ListGreaterThan(arg INT) "
40 + " BEGIN "
41 + " SELECT * "
42 + " FROM Test1 "
43 + " WHERE A > arg; "
44 + " END; ");
45 cs = conn.prepareCall("CALL ListGreaterThan(?)");
46 // Note that we use the same "?" placeholder
47 // than we used for prepared statement.
48
49 // We declare an int variable for the argument
50 // for the sake of clarity, but don't need to.
51 int x = 2;
52 // We set the value of the first "? slot"
53 // using setInt as for prepared statements.
54 cs.setInt(1, x); // 1 is the position
55
56 rset = cs.executeQuery();
57 System.out.println("The values of A greater than " + x + " are:");
58 while (rset.next()) {
59 System.out.println("The value of A is " + rset.getInt("A") + ".");
60 }
41 61
42 62 conn.close(); conn.close();
43 63 } catch (SQLException ex) { } catch (SQLException ex) {
File notes/code/java/TestingSemicolon.java changed (mode: 100644) (index f906c2a..2726383)
... ... public class TestingSemicolon {
25 25 try (Connection conn = try (Connection conn =
26 26 DriverManager.getConnection( DriverManager.getConnection(
27 27 "jdbc:mysql://localhost:3306/?user=testuser&password=password"); // without + "jdbc:mysql://localhost:3306/?user=testuser&password=password"); // without +
28 // "&allowMultiQueries=true"
28 // "&allowMultiQueries=true"
29 29 Statement stmt = conn.createStatement(); ) { Statement stmt = conn.createStatement(); ) {
30 30 stmt.addBatch("DROP SCHEMA IF EXISTS HW_Testing_Semicolon"); stmt.addBatch("DROP SCHEMA IF EXISTS HW_Testing_Semicolon");
31 31 stmt.addBatch("CREATE SCHEMA HW_Testing_Semicolon"); stmt.addBatch("CREATE SCHEMA HW_Testing_Semicolon");
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/caubert/CSCI_3410

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/caubert/CSCI_3410

Clone this repository using git:
git clone git://git.rocketgit.com/user/caubert/CSCI_3410

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main