Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plante-qui-pleure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Puissegur Alexis
plante-qui-pleure
Commits
6c41fa49
Commit
6c41fa49
authored
6 years ago
by
Puissegur Alexis
Browse files
Options
Downloads
Patches
Plain Diff
adding sqlitedb + table + insert methods
parent
c40d27fe
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/nbproject/project.properties
+3
-1
3 additions, 1 deletion
app/nbproject/project.properties
app/src/Vue/FXMLVueController.java
+83
-1
83 additions, 1 deletion
app/src/Vue/FXMLVueController.java
app/src/app/App.java
+1
-0
1 addition, 0 deletions
app/src/app/App.java
with
87 additions
and
2 deletions
app/nbproject/project.properties
+
3
−
1
View file @
6c41fa49
...
...
@@ -31,6 +31,7 @@ endorsed.classpath=
excludes
=
file.reference.bluecove-2.1.1-SNAPSHOT.jar
=
bluecove-2.1.1-SNAPSHOT.jar
file.reference.javax.mail-api-1.4.7.jar
=
javax.mail-api-1.4.7.jar
file.reference.sqlite-jdbc-3.23.1.jar
=
C:
\\
Users
\\
puiss
\\
Downloads
\\
sqlite-jdbc-3.23.1.jar
includes
=
**
# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects
jar.archive.disabled
=
true
...
...
@@ -38,7 +39,8 @@ jar.compress=false
javac.classpath
=
\
${javafx.classpath.extension}:
\
${file.reference.bluecove-2.1.1-SNAPSHOT.jar}:
\
${file.reference.javax.mail-api-1.4.7.jar}
${file.reference.javax.mail-api-1.4.7.jar}:
\
${file.reference.sqlite-jdbc-3.23.1.jar}
# Space-separated list of extra javac options
javac.compilerargs
=
javac.deprecation
=
false
...
...
This diff is collapsed.
Click to expand it.
app/src/Vue/FXMLVueController.java
+
83
−
1
View file @
6c41fa49
...
...
@@ -40,6 +40,12 @@ import javafx.scene.control.ToggleGroup;
import
javafx.scene.layout.GridPane
;
import
javafx.scene.layout.HBox
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
/**
* FXML Controller class
*
...
...
@@ -196,9 +202,85 @@ public class FXMLVueController implements Initializable, Observer {
graph
.
getData
().
add
(
serieLine
);
graph
.
setLegendVisible
(
false
);
initDB
(
"plant.db"
);
}
public
static
void
initDB
(
String
name
)
{
String
url
=
"jdbc:sqlite:C:/sqlite/"
+
name
;
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
))
{
if
(
conn
!=
null
)
{
DatabaseMetaData
meta
=
conn
.
getMetaData
();
createNewTable
(
url
);
}
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
}
/**
* Create a new table in the test database
*
*/
public
static
void
createNewTable
(
String
url
)
{
// SQLite connection string
// SQL statement for creating a new table
String
sql
=
"CREATE TABLE IF NOT EXISTS data (\n"
+
" id integer PRIMARY KEY AUTOINCREMENT,\n"
+
" month integer NOT NULL CHECK(month <= 12 and month > 0),\n"
+
" day integer NOT NULL CHECK(day <= 31 and day > 0),\n"
+
" hour integer NOT NULL CHECK(hour <24 and hour >= 0),\n"
+
" min integer NOT NULL CHECK(min <60 and min >= 0),\n"
+
" intensity integer,\n"
+
" temperature integer,\n"
+
" humidityAir integer,\n"
+
" humidityPlant integer\n"
+
");"
;
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
);
Statement
stmt
=
conn
.
createStatement
())
{
// create a new table
stmt
.
execute
(
sql
);
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"ewi"
+
e
.
getMessage
());
}
}
private
Connection
connect
()
{
// SQLite connection string
String
url
=
"jdbc:sqlite:C://sqlite/plant.db"
;
Connection
conn
=
null
;
try
{
conn
=
DriverManager
.
getConnection
(
url
);
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
return
conn
;
}
public
void
insert
(
int
month
,
int
day
,
int
hour
,
int
min
,
int
it
,
int
temp
,
int
humiA
,
int
humiT
)
{
String
sql
=
"INSERT INTO data(month,day,hour,min,intensity,temperature,humidityAir,humidityPlant) VALUES(?,?,?,?,?,?,?,?)"
;
try
(
Connection
conn
=
this
.
connect
();
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
sql
))
{
pstmt
.
setInt
(
1
,
month
);
pstmt
.
setInt
(
2
,
day
);
pstmt
.
setInt
(
3
,
hour
);
pstmt
.
setInt
(
4
,
min
);
pstmt
.
setInt
(
5
,
it
);
pstmt
.
setInt
(
6
,
temp
);
pstmt
.
setInt
(
7
,
humiA
);
pstmt
.
setInt
(
8
,
humiT
);
pstmt
.
executeUpdate
();
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
}
/**
* Change the text for activate or desactivate according to the checkbox
* @param event
...
...
This diff is collapsed.
Click to expand it.
app/src/app/App.java
+
1
−
0
View file @
6c41fa49
...
...
@@ -14,6 +14,7 @@ import Vue.*;
import
java.io.IOException
;
import
javafx.scene.image.Image
;
/**
*
* @author invite
...
...
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