Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
postprocessing
Media Converter
Commits
f45b6ed6
Unverified
Commit
f45b6ed6
authored
Jun 02, 2020
by
Sebastian Schüpbach
Browse files
provide basic db communication means
parent
a18265c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
build.sbt
View file @
f45b6ed6
...
...
@@ -25,6 +25,7 @@ lazy val root = (project in file("."))
log4jCore
,
log4jSlf4j
,
log4jScala
,
mariadbJdbcDriver
,
memobaseServiceUtils
,
scalatic
,
scalaTest
%
Test
)
...
...
project/Dependencies.scala
View file @
f45b6ed6
...
...
@@ -28,6 +28,7 @@ object Dependencies {
lazy
val
log4jCore
=
"org.apache.logging.log4j"
%
"log4j-core"
%
log4jV
lazy
val
log4jScala
=
"org.apache.logging.log4j"
%%
"log4j-api-scala"
%
"11.0"
lazy
val
log4jSlf4j
=
"org.apache.logging.log4j"
%
"log4j-slf4j-impl"
%
log4jV
lazy
val
mariadbJdbcDriver
=
"org.mariadb.jdbc"
%
"mariadb-java-client"
%
"2.6.0"
lazy
val
memobaseServiceUtils
=
"org.memobase"
%
"memobase-service-utilities"
%
"1.2.1"
lazy
val
scalatic
=
"org.scalactic"
%%
"scalactic"
%
scalatestV
lazy
val
scalaTest
=
"org.scalatest"
%%
"scalatest"
%
scalatestV
...
...
src/main/scala/org/memobase/utils/DBHandler.scala
0 → 100644
View file @
f45b6ed6
/*
* Extracts media files from Fedora repository
* Copyright (C) 2020 Memoriav
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org.memobase.utils
import
java.sql.
{
Connection
,
DriverManager
}
import
org.apache.logging.log4j.scala.Logging
class
DBHandler
(
connection
:
Connection
,
table
:
String
)
{
def
insert
(
sig
:
String
,
uri
:
String
)
:
Boolean
=
{
val
st
=
connection
.
createStatement
()
val
res
=
st
.
executeQuery
(
s
"UPDATE $table SET uri=$uri WHERE sig=$sig"
)
}
def
close
()
:
Unit
=
{
connection
.
close
()
}
}
object
DBHandler
extends
Logging
{
def
apply
(
host
:
String
,
port
:
Int
,
user
:
String
,
password
:
String
,
table
:
String
)
:
DBHandler
=
{
logger
.
info
(
s
"Connecting to mediaserver database on $host:$port"
)
val
connection
=
DriverManager
.
getConnection
(
s
"jdbc:mariadb://$host:$port/DB?user=$user&password=$password"
);
new
DBHandler
(
connection
,
table
)
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment