Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
5b0c7ce5
Commit
5b0c7ce5
authored
12 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
smaller corrections
parent
71b885d7
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
Doc/Ref/Fig/jdbcSniffing.fig
+3
-2
3 additions, 2 deletions
Doc/Ref/Fig/jdbcSniffing.fig
Doc/course.xml
+54
-12
54 additions, 12 deletions
Doc/course.xml
ws/eclipse/Jdbc/src/sda/jdbc/intro/v1/SimpleInsert.java
+9
-6
9 additions, 6 deletions
ws/eclipse/Jdbc/src/sda/jdbc/intro/v1/SimpleInsert.java
with
66 additions
and
20 deletions
Doc/Ref/Fig/jdbcSniffing.fig
+
3
−
2
View file @
5b0c7ce5
...
...
@@ -294,8 +294,9 @@ Single
1 1 1.00 60.00 120.00
3330 3735 3330 4410
2 5 0 1 0 -1 740 -1 20 0.000 0 0 -1 0 0 5
0
/ma/goik/Downloads/
hacker.p
n
g
2520 2
47
5 4
246 2475 4246
36
76
2520 36
76
2520 2
47
5
0 hacker.
j
pg
2520 2
38
5 4
320 2385 4320
36
09
2520 36
09
2520 2
38
5
4 0 0 800 0 18 12 0.0000 4 150 600 990 1350 Server\001
4 0 0 780 0 18 12 0.0000 4 150 540 6255 1350 Client\001
4 0 0 760 0 18 12 0.0000 4 150 645 3330 4995 TCP/IP\001
4 0 0 740 0 18 12 0.0000 4 150 735 2970 2205 Intruder\001
This diff is collapsed.
Click to expand it.
Doc/course.xml
+
54
−
12
View file @
5b0c7ce5
...
...
@@ -27,6 +27,48 @@
<chapter
xml:id=
"prerequisites"
>
<title>
Prerequisites
</title>
<section
xml:id=
"resources"
>
<title>
Lecture resources
</title>
<para>
A
<uri
xlink:href=
"https://www.virtualbox.org"
>
Virtualbox
</uri>
based virtual machine is available at
<uri
xlink:href=
"ftp://mirror.mi.hdm-stuttgart.de/ubuntu/VirtualBox/lubuntu.vdi"
>
ftp://mirror.mi.hdm-stuttgart.de/ubuntu/VirtualBox/lubuntu.vdi
</uri>
.
It contains all (??) related tools from the
<uri
xlink:href=
"http://www.mi.hdm-stuttgart.de"
>
CSM
</uri>
department's
lecture room Linux installation:
</para>
<itemizedlist>
<listitem>
<para>
Eclipse J2EE version with
<productname>
Database developer
tools
</productname>
,
<productname>
git
</productname>
,
<trademark>
Oxygenxml
</trademark>
, and
<productname>
svn
</productname>
plugins installed.
</para>
</listitem>
<listitem>
<para>
A running
<productname>
Mysql
</productname>
server
preconfigured with user
<quote><code>
hdmuser
</code></quote>
,
password
<quote><code>
XYZ
</code></quote>
and database
<quote><code>
hdm
</code></quote>
.
</para>
</listitem>
<listitem>
<para><productname>
Xmlmind
</productname>
editor for visually editing
technical documents based on
<uri
xlink:href=
"http://docbook.org/tdg5/index.html"
>
docbook
</uri>
or
<uri
xlink:href=
"http://en.wikipedia.org/wiki/Darwin_Information_Typing_Architecture"
>
DITA
</uri>
.
</para>
</listitem>
<listitem>
<para>
Based on the
<uri
xlink:href=
"http://lubuntu.net"
>
Lubuntu
</uri>
fork of
<uri
xlink:href=
"http://www.ubuntu.com"
>
Ubuntu
</uri>
for resource saving
reasons with respect to be used in a virtualized environment.
</para>
</listitem>
</itemizedlist>
</section>
<section
xml:id=
"tools"
>
<title>
Tools
</title>
...
...
@@ -178,7 +220,7 @@ java version "1.7.0_07"
<para>
We start by installing the
<productname>
mysql
</productname>
server:
</para>
<programlisting>
root@goiki:~# aptitude install mysql-server
-5.5
<programlisting>
root@goiki:~# aptitude install mysql-server
The following NEW packages will be installed:
libdbd-mysql-perl{a} libdbi-perl{a} libnet-daemon-perl{a} libplrpc-perl{a}
mysql-client-5.5{a} mysql-server-5.5
...
...
@@ -698,18 +740,19 @@ SimpleInsert.username=hdmuser</programlisting>
</informalfigure>
<para>
The wizard also generates a class
<classname>
sda.jdbc.intro.v1.
JdbcPropertie
s
</classname>
to
actually
access our properties:
</para>
<classname>
sda.jdbc.intro.v1.
DbProp
s
</classname>
to
actually
access our properties:
</para>
<programlisting
language=
"java"
>
package sda.jdbc.intro.v1;
...
public class
JdbcPropertie
s {
private static final String BUNDLE_NAME = "sda.jdbc.intro.v1.
jdbc
";
public class
DbProp
s {
private static final String BUNDLE_NAME = "sda.jdbc.intro.v1.
database
";
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private JdbcProperties() {}
private DbProps() {
}
public static String getString(String key) {
try {
...
...
@@ -2152,7 +2195,7 @@ INSERT INTO Person VALUES ('Pete', 'p@rr.com')
linkend=
"figJdbcSimpleWrite"
/>
may be rewritten using
<classname>
java.sql.PreparedStatement
</classname>
objects:
</para>
<programlisting
language=
"java"
>
package
sda.jdbc.
prepare
;
<programlisting
language=
"java"
>
sda.jdbc.
intro.v1
;
...
public class SimpleInsert {
...
...
@@ -2230,9 +2273,8 @@ public class SimpleInsert {
<para>
Due to our separation of GUI and persistence handling
we only need to re-implement
<classname>
sda.jdbc.intro.sqlinject.PersistenceHandler
</classname>
.
We have to replace
<classname>
java.util.Statement
</classname>
by
<classname>
java.util.PreparedStatement
</classname>
We have to replace
<classname>
java.sql.Statement
</classname>
by
<classname>
java.sql.PreparedStatement
</classname>
instances. A possible implementation is
<classname>
sda.jdbc.intro.v1.prepare.PersistenceHandler
</classname>
.
We may now safely enter offending strings like:
</para>
...
...
@@ -2986,8 +3028,8 @@ public class InsertPerson extends JFrame {
<para>
Password fields need special treatment:
<code>
getText()
</code>
is superseded by
<code>
getPassword()
</code>
. In order to avoid casts from
<classname>
javax.swing.JTextField
.JTextField
</classname>
to
<classname>
javax.swing.JPasswordField
</classname>
we
<classname>
javax.swing.JTextField
</classname>
to
<classname>
javax.swing.JPasswordField
</classname>
we
simply keep an extra reference.
</para>
</callout>
...
...
This diff is collapsed.
Click to expand it.
ws/eclipse/Jdbc/src/sda/jdbc/intro/v1/SimpleInsert.java
+
9
−
6
View file @
5b0c7ce5
...
...
@@ -2,8 +2,8 @@ package sda.jdbc.intro.v1;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
public
class
SimpleInsert
{
...
...
@@ -15,12 +15,15 @@ public class SimpleInsert {
DbProps
.
getString
(
"PersistenceHandler.username"
),
DbProps
.
getString
(
"PersistenceHandler.password"
));
// Step 2: Create a Statement instance
final
Statement
s
tmt
=
conn
.
c
re
at
eStatement
();
// Step 2: Create a
Prepared
Statement instance
final
Prepared
Statement
pS
tmt
=
conn
.
p
re
par
eStatement
(
"INSERT INTO Person VALUES(?, ?)"
);
// Step 3: Execute the desired INSERT
final
int
updateCount
=
stmt
.
executeUpdate
(
"INSERT INTO Person VALUES('Jim', 'jim@foo.org')"
);
// Step 3a: Fill in desired attribute values
pStmt
.
setString
(
1
,
"Jim"
);
pStmt
.
setString
(
2
,
"jim@foo.org"
);
// Step 3b: Execute the desired INSERT
final
int
updateCount
=
pStmt
.
executeUpdate
();
// Step 4: Give feedback to the enduser
System
.
out
.
println
(
"Successfully inserted "
+
updateCount
+
" dataset(s)"
);
...
...
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