5
5
import org .slf4j .LoggerFactory ;
6
6
7
7
import java .sql .PreparedStatement ;
8
- import java .sql .SQLException ;
9
8
import java .sql .ResultSet ;
9
+ import java .sql .SQLException ;
10
10
import java .util .ArrayList ;
11
11
import java .util .List ;
12
12
@@ -38,6 +38,7 @@ private DaoMusicType() {
38
38
39
39
/**
40
40
* Return instance of this.
41
+ *
41
42
* @return instance of this.
42
43
*/
43
44
public static DaoMusicType getInstance () {
@@ -46,6 +47,7 @@ public static DaoMusicType getInstance() {
46
47
47
48
/**
48
49
* SQL query which select all from table.
50
+ *
49
51
* @return SQL query for collect all order from concrete table.
50
52
*/
51
53
@ Override
@@ -55,6 +57,7 @@ public String getSelectAll() {
55
57
56
58
/**
57
59
* SQL query which select all data from one row.
60
+ *
58
61
* @return SQL query for collect data from one row.
59
62
*/
60
63
@ Override
@@ -64,6 +67,7 @@ public String getSelectById() {
64
67
65
68
/**
66
69
* SQL query which edit object at the system.
70
+ *
67
71
* @return SQL query which edit object in the concrete table.
68
72
*/
69
73
@ Override
@@ -73,6 +77,7 @@ public String getEdit() {
73
77
74
78
/**
75
79
* SQL query which remove order about object from concrete table.
80
+ *
76
81
* @return SQL query which remove order about object at the concrete table.
77
82
*/
78
83
@ Override
@@ -82,6 +87,7 @@ public String getRemove() {
82
87
83
88
/**
84
89
* SQL query which insert data to the database.
90
+ *
85
91
* @return SQL INSERT for concrete table.
86
92
*/
87
93
@ Override
@@ -91,37 +97,38 @@ public String getInsert() {
91
97
92
98
/**
93
99
* Set data to the statement.
100
+ *
94
101
* @param statement instance of PreparedStatement.
95
- * @param object instance of class.
102
+ * @param object instance of class.
96
103
*/
97
104
@ Override
98
105
public void prepareStatementForInsert (PreparedStatement statement , MusicType object ) {
99
106
try {
100
107
statement .setString (1 , object .getType ());
101
108
} catch (SQLException e ) {
102
- log .error (e .getMessage (), e );
103
- throw new RuntimeException ("Failed to prepare insert statement" , e );
109
+ log .warn (e .getMessage (), e );
104
110
}
105
111
}
106
112
107
113
/**
108
114
* Set data to the statement.
115
+ *
109
116
* @param statement instance of PreparedStatement.
110
- * @param object instance of class.
117
+ * @param object instance of class.
111
118
*/
112
119
@ Override
113
120
public void prepareStatementForUpdate (PreparedStatement statement , MusicType object ) {
114
121
try {
115
122
statement .setString (1 , object .getType ());
116
123
statement .setInt (2 , object .getId ());
117
124
} catch (SQLException e ) {
118
- log .error (e .getMessage (), e );
119
- throw new RuntimeException ("Failed to prepare update statement" , e );
125
+ log .warn (e .getMessage (), e );
120
126
}
121
127
}
122
128
123
129
/**
124
130
* Set data to the statement.
131
+ *
125
132
* @param set instance of result set interface.
126
133
* @return list of music types.
127
134
*/
@@ -135,8 +142,7 @@ public List<MusicType> parseResultSet(ResultSet set) {
135
142
list .add (new MusicType (id , type ));
136
143
}
137
144
} catch (SQLException e ) {
138
- log .error (e .getMessage (), e );
139
- throw new RuntimeException ("Failed to parse result set" , e );
145
+ log .warn (e .getMessage (), e );
140
146
}
141
147
142
148
return list ;
0 commit comments