|
7 | 7 | <link rel="stylesheet" href="checker.css"> |
8 | 8 | <script src="js-yaml.min.js"></script> |
9 | 9 | <script src="checker.js"></script> |
| 10 | +<script src="hardcoded.js"></script> |
10 | 11 | <link rel="license" href="https://creativecommons.org/licenses/by/4.0/"> |
11 | 12 |
|
12 | 13 | <!-- See create_labs.md for how to create your own lab! --> |
|
24 | 25 | System \. getenv \( "PASSWORD" \) \) \; \s* |
25 | 26 | </script> |
26 | 27 |
|
27 | | -<script id="info" type="application/yaml"> |
28 | | ---- |
29 | | -hints: |
30 | | -- absent: | |
31 | | - ^ \s* conn = DriverManager \. getConnection \( url \, |
32 | | - text: > |
33 | | - Your answer should start with |
34 | | - `conn = DriverManager.getConnection( url,` |
35 | | - just as the initial value did. You might want to use the `Reset` button. |
36 | | -- absent: | |
37 | | - System \. getenv |
38 | | - text: > |
39 | | - Use `System.getenv` to retrieve an environment variable value. |
40 | | - For example, use `System.getenv("USERNAME")` to retrieve the username. |
41 | | -- present: | |
42 | | - System \. getenv \( \"admin\" \) |
43 | | - text: > |
44 | | - You need to pass to |
45 | | - `System.getenv` the name of an environment variable value, not the |
46 | | - result you might get. |
47 | | - Do not use constructs like `System.getenv("admin")`. |
48 | | - Instead, for example, |
49 | | - use `System.getenv("USERNAME")` to retrieve the username. |
50 | | -- absent: | |
51 | | - System \. getenv \( \"PASSWORD\" \) |
52 | | - text: > |
53 | | - Use `System.getenv` to retrieve an environment variable value. |
54 | | - For example, use `System.getenv("USERNAME")` to retrieve the username. |
55 | | -- present: "admin" |
56 | | - text: > |
57 | | - The term 'admin' should not be in your code. |
58 | | - You should be retrieving both the username and the password |
59 | | - from somewhere else, in this case, from environment variables. |
60 | | -- present: | |
61 | | - (system|Getenv|GetEnv) |
62 | | - text: > |
63 | | - Java is case-sensitive. You need to use |
64 | | - `System.getenv` and not some other variation of uppercase or lowercase. |
65 | | -- absent: |- |
66 | | - \; \s* $ |
67 | | - text: > |
68 | | - Java statements must end with a semicolon. |
69 | | -- absent: | |
70 | | - \) \) \; \s* $ |
71 | | - text: > |
72 | | - Double-check your closing parentheses at the end of the statement. |
73 | | -- present: | |
74 | | - new\s+String |
75 | | - text: > |
76 | | - You do not need to construct a new string to retrieve an |
77 | | - environment variable value. |
78 | | -- present: | |
79 | | - ^ conn = DriverManager \. getConnection \( url \) \; \s* $ |
80 | | - text: > |
81 | | - In some sense this is correct, as long as the url is not hardcoded. |
82 | | - However, it's often better if administrators can easily change the |
83 | | - username or password separately, and it makes out point clearer. |
84 | | - Please provide the username and password and separate values. |
85 | | -- present: | |
86 | | - ^ \s* conn = DriverManager \. getConnection \( url \, |
87 | | - System \. getenv \( "PASSWORD" \) \, |
88 | | - System \. getenv \( "USERNAME" \) \) \; \s* $ |
89 | | - text: > |
90 | | - The order of parameters is wrong. Provide the url, then the username, |
91 | | - then the password. You're providing the url, then the password, then |
92 | | - the username, which swaps the second and third parameters. |
93 | | -# debug: true |
94 | | -</script> |
95 | 28 | </head> |
96 | 29 | <body> |
97 | 30 | <!-- For GitHub Pages formatting: --> |
|
0 commit comments