Revision 50947
Added by Argiro Kokogiannaki about 6 years ago
SqlStore.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
public void init() throws ClassNotFoundException, SQLException { |
38 | 38 |
Class.forName(dbDriver); |
39 |
this.getConnection(); |
|
39 |
// this.getConnection();
|
|
40 | 40 |
|
41 | 41 |
|
42 | 42 |
} |
... | ... | |
59 | 59 |
*/ |
60 | 60 |
public void getConnectionNoDatabase() throws SQLException { |
61 | 61 |
String parsedUrl = this.parseUrl(dbUrl); |
62 |
log.info("Connecting to " + parsedUrl + dbUser + dbPassword);
|
|
62 |
log.info("Connecting to " + parsedUrl + dbUser ); |
|
63 | 63 |
connection = (Connection) DriverManager.getConnection(parsedUrl, dbUser, dbPassword); |
64 | 64 |
log.info("Connected to " + parsedUrl); |
65 | 65 |
|
... | ... | |
72 | 72 |
*/ |
73 | 73 |
public void getConnection() throws SQLException { |
74 | 74 |
|
75 |
log.info("Attempting connection to : " + this.dbUrl + " for " + this.dbUser + " and " + this.dbPassword);
|
|
75 |
log.info("Attempting connection to : " + this.dbUrl + " for " + this.dbUser ); |
|
76 | 76 |
connection = (Connection) DriverManager.getConnection(this.dbUrl, dbUser, dbPassword); |
77 | 77 |
log.info("Connected to " + this.dbUrl); |
78 | 78 |
|
... | ... | |
150 | 150 |
*/ |
151 | 151 |
public ResultSet executeQuery(String command) throws SQLException, SQLStoreException { |
152 | 152 |
log.debug(" Executing Query ... " + command); |
153 |
try{ |
|
154 |
this.getConnection(); |
|
153 | 155 |
Statement st = connection.createStatement(); |
154 | 156 |
|
155 | 157 |
if (st.execute(command)) { |
... | ... | |
163 | 165 |
|
164 | 166 |
} |
165 | 167 |
|
168 |
} finally { |
|
169 |
this.closeConnection(); |
|
170 |
} |
|
166 | 171 |
|
167 |
|
|
168 | 172 |
} |
169 | 173 |
|
170 | 174 |
/** |
... | ... | |
178 | 182 |
*/ |
179 | 183 |
public ResultSet executeQuery(String command, ArrayList<Object> values) throws SQLException, SQLStoreException { |
180 | 184 |
log.debug(" Executing Query ..." + command); |
181 |
|
|
185 |
try{ |
|
186 |
this.getConnection(); |
|
182 | 187 |
PreparedStatement st = connection.prepareStatement(command); |
183 | 188 |
|
184 | 189 |
int pos = 1; |
... | ... | |
199 | 204 |
throw new SQLStoreException("Fail to execute command " + st.getWarnings()); |
200 | 205 |
} |
201 | 206 |
|
207 |
} finally { |
|
208 |
this.closeConnection(); |
|
209 |
} |
|
202 | 210 |
|
203 |
|
|
204 | 211 |
} |
205 | 212 |
|
206 | 213 |
/** |
... | ... | |
212 | 219 |
*/ |
213 | 220 |
public void executeUpdate(String command) throws SQLException { |
214 | 221 |
log.debug(" Executing Query ..." + command); |
222 |
try{ |
|
223 |
this.getConnection(); |
|
215 | 224 |
Statement st = connection.createStatement(); |
216 | 225 |
st.executeUpdate(command); |
217 | 226 |
//st.close(); |
227 |
} finally { |
|
228 |
this.closeConnection(); |
|
229 |
} |
|
218 | 230 |
} |
219 | 231 |
public void executeUpdateWithRollback(List<String> commandS) throws SQLException{ |
220 | 232 |
log.debug(" Executing Query ..." + commandS); |
Also available in: Unified diff
close the db connection per request, in fetch claims by context id use like and wild character in order to get all claims of a community