@@ -74,13 +74,17 @@ class JdbcRDD[T: ClassTag](
74
74
}
75
75
76
76
def getSchema : Seq [(String , Int , Boolean )] = {
77
- if (null != schema) return schema
77
+ if (null != schema) {
78
+ return schema
79
+ }
78
80
79
81
val conn = getConnection()
80
82
val stmt = conn.prepareStatement(sql)
81
83
val metadata = stmt.getMetaData
82
84
try {
83
- if (null != stmt && ! stmt.isClosed()) stmt.close()
85
+ if (null != stmt && ! stmt.isClosed()) {
86
+ stmt.close()
87
+ }
84
88
} catch {
85
89
case e : Exception => logWarning(" Exception closing statement" , e)
86
90
}
@@ -110,8 +114,12 @@ class JdbcRDD[T: ClassTag](
110
114
}
111
115
112
116
val parameterCount = stmt.getParameterMetaData.getParameterCount
113
- if (parameterCount > 0 ) stmt.setLong(1 , part.lower)
114
- if (parameterCount > 1 ) stmt.setLong(2 , part.upper)
117
+ if (parameterCount > 0 ) {
118
+ stmt.setLong(1 , part.lower)
119
+ }
120
+ if (parameterCount > 1 ) {
121
+ stmt.setLong(2 , part.upper)
122
+ }
115
123
116
124
val rs = stmt.executeQuery()
117
125
@@ -126,17 +134,23 @@ class JdbcRDD[T: ClassTag](
126
134
127
135
override def close () {
128
136
try {
129
- if (null != rs && ! rs.isClosed()) rs.close()
137
+ if (null != rs && ! rs.isClosed()) {
138
+ rs.close()
139
+ }
130
140
} catch {
131
141
case e : Exception => logWarning(" Exception closing resultset" , e)
132
142
}
133
143
try {
134
- if (null != stmt && ! stmt.isClosed()) stmt.close()
144
+ if (null != stmt && ! stmt.isClosed()) {
145
+ stmt.close()
146
+ }
135
147
} catch {
136
148
case e : Exception => logWarning(" Exception closing statement" , e)
137
149
}
138
150
try {
139
- if (null != conn && ! conn.isClosed()) conn.close()
151
+ if (null != conn && ! conn.isClosed()) {
152
+ conn.close()
153
+ }
140
154
logInfo(" closed connection" )
141
155
} catch {
142
156
case e : Exception => logWarning(" Exception closing connection" , e)
@@ -150,3 +164,4 @@ object JdbcRDD {
150
164
Array .tabulate[Object ](rs.getMetaData.getColumnCount)(i => rs.getObject(i + 1 ))
151
165
}
152
166
}
167
+
0 commit comments