Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pizzeria-del-SAE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gwendal Margely
Pizzeria-del-SAE
Commits
95f1407a
Commit
95f1407a
authored
1 year ago
by
Gwendal Margely
Browse files
Options
Downloads
Patches
Plain Diff
ajout doc et modif IngredientDAO.java
parent
127dfc41
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Documentation/documentation.md
+27
-0
27 additions, 0 deletions
Documentation/documentation.md
WEB-INF/src/DAO/IngredientDAO.java
+5
-4
5 additions, 4 deletions
WEB-INF/src/DAO/IngredientDAO.java
with
32 additions
and
4 deletions
Documentation/documentation.md
0 → 100644
+
27
−
0
View file @
95f1407a
# Documentation pour les tables et les requetes
## Table Ingrédients
### Création de la table
```
sql
/*au cas ou l'on voudrait être un terroriste et enlever la table si elle existe déja DROP TABLE IF EXISTS ingredients CASCADE;*/
CREATE
TABLE
ingredients
(
id
INT
PRIMARY
KEY
,
nom
TEXT
UNIQUE
,
price
REAL
);
INSERT
INTO
TABLE
ingredients
(
id
,
nom
,
price
)
VALUES
(
1
,
'jambon'
,
2
.
00
),(
2
,
'poivrons'
,
3
.
00
),(
3
,
'mozarella'
,
2
.
50
),(
4
,
'lardons'
,
2
.
20
),(
5
,
'miel'
,
3
.
50
),(
6
,
'chorizo'
,
4
.
00
);
```
### Requête sur la table
FIND ALL
```
sql
SELECT
nom
,
price
FROM
ingredients
;
```
Sélectionner seulement un ingrédient
\
les ? représentent l'élément passé en argument
```
sql
SELECT
nom
,
price
,
FROM
ingr
é
dient
where
id
=
?
;
```
This diff is collapsed.
Click to expand it.
WEB-INF/src/DAO/IngredientDAO.java
+
5
−
4
View file @
95f1407a
package
DAO
;
import
Exceptions.IngredientDAOException
;
import
POJO.Ingredient
;
...
...
@@ -19,8 +20,8 @@ public class IngredientDAO {
// SQL queries
private
static
final
String
SELECT_ALL_QUERY
=
"SELECT * FROM ingredients"
;
private
static
final
String
INSERT_QUERY
=
"INSERT INTO ingredients(n
ame
, price) VALUES (?, ?)"
;
private
static
final
String
SELECT_BY_ID_QUERY
=
"SELECT
*
FROM ingredients WHERE id = ?"
;
private
static
final
String
INSERT_QUERY
=
"INSERT INTO ingredients(n
om
, price) VALUES (?, ?)"
;
private
static
final
String
SELECT_BY_ID_QUERY
=
"SELECT
nom,price
FROM ingredients WHERE id = ?"
;
private
static
final
String
DELETE_QUERY
=
"DELETE FROM ingredients WHERE id = ?"
;
// Method to establish database connection
...
...
@@ -60,7 +61,7 @@ public class IngredientDAO {
while
(
resultSet
.
next
())
{
int
id
=
resultSet
.
getInt
(
"id"
);
String
name
=
resultSet
.
getString
(
"n
ame
"
);
String
name
=
resultSet
.
getString
(
"n
om
"
);
double
price
=
resultSet
.
getDouble
(
"price"
);
Ingredient
ingredient
=
new
Ingredient
(
id
,
name
,
price
);
ingredients
.
add
(
ingredient
);
...
...
@@ -99,7 +100,7 @@ public class IngredientDAO {
resultSet
=
preparedStatement
.
executeQuery
();
if
(
resultSet
.
next
())
{
String
name
=
resultSet
.
getString
(
"n
ame
"
);
String
name
=
resultSet
.
getString
(
"n
om
"
);
double
price
=
resultSet
.
getDouble
(
"price"
);
ingredient
=
new
Ingredient
(
id
,
name
,
price
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment