1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.test.function;
|
11
|
|
12
|
import java.io.IOException;
|
13
|
import java.sql.ResultSet;
|
14
|
import java.sql.SQLException;
|
15
|
import java.util.ArrayList;
|
16
|
import java.util.Arrays;
|
17
|
import java.util.List;
|
18
|
import java.util.UUID;
|
19
|
|
20
|
import org.apache.log4j.Level;
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.hibernate.Query;
|
23
|
import org.hibernate.Session;
|
24
|
import org.springframework.transaction.TransactionStatus;
|
25
|
|
26
|
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
27
|
import eu.etaxonomy.cdm.api.application.CdmApplicationUtils;
|
28
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
29
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
30
|
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
|
31
|
import eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO;
|
32
|
import eu.etaxonomy.cdm.common.AccountStore;
|
33
|
import eu.etaxonomy.cdm.database.CdmDataSource;
|
34
|
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
|
35
|
import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
|
36
|
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
|
37
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
38
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
39
|
import eu.etaxonomy.cdm.model.agent.Person;
|
40
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
41
|
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException;
|
42
|
import eu.etaxonomy.cdm.model.description.Distribution;
|
43
|
import eu.etaxonomy.cdm.model.description.FeatureNode;
|
44
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
45
|
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
46
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
47
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
48
|
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
|
49
|
import eu.etaxonomy.cdm.model.name.IBotanicalName;
|
50
|
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
|
51
|
import eu.etaxonomy.cdm.model.name.Rank;
|
52
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
53
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
54
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
55
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
56
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
57
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
58
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
59
|
|
60
|
public class Datasource {
|
61
|
private static final Logger logger = Logger.getLogger(Datasource.class);
|
62
|
|
63
|
|
64
|
private void testNewConfigControler(){
|
65
|
List<CdmPersistentDataSource> lsDataSources = CdmPersistentDataSource.getAllDataSources();
|
66
|
DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
|
67
|
|
68
|
String server;
|
69
|
String database;
|
70
|
String username;
|
71
|
|
72
|
System.out.println(lsDataSources);
|
73
|
ICdmDataSource dataSource;
|
74
|
|
75
|
dataSource = lsDataSources.get(1);
|
76
|
// DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
|
77
|
|
78
|
// String server = "localhost";
|
79
|
// database = "cdm36";
|
80
|
//// database = "cdm_production_edaphobase";
|
81
|
// String username = "edit";
|
82
|
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
83
|
|
84
|
// String server = "160.45.63.171";
|
85
|
// String database = "cdm_production_xxx";
|
86
|
// String username = "edit";
|
87
|
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
88
|
|
89
|
|
90
|
// String server = "test.e-taxonomy.eu";
|
91
|
//// String database = "cdm_test";
|
92
|
// String database = "cdm_edit_flora_malesiana";
|
93
|
// String username = "edit";
|
94
|
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
95
|
|
96
|
// String server = "localhost";
|
97
|
// String database = "testCDM";
|
98
|
// String username = "postgres";
|
99
|
// dataSource = CdmDataSource.NewInstance(DatabaseTypeEnum.PostgreSQL, server, database, DatabaseTypeEnum.PostgreSQL.getDefaultPort(), username, AccountStore.readOrStorePassword(server, database, username, null));
|
100
|
|
101
|
|
102
|
//SQLServer
|
103
|
server = "BGBM-PESISQL";
|
104
|
database = "cdm36";
|
105
|
int port = 1433;
|
106
|
username = "cdmupdater";
|
107
|
dataSource = CdmDataSource.NewSqlServer2012Instance(server, database, port, username, AccountStore.readOrStorePassword(server, database, username, null));
|
108
|
//
|
109
|
// //H2
|
110
|
// String path = "C:\\Users\\a.mueller\\.cdmLibrary\\writableResources\\h2\\LocalH2";
|
111
|
//// String path = "C:\\Users\\pesiimport\\.cdmLibrary\\writableResources\\h2\\LocalH2";
|
112
|
//// String path = "C:\\Users\\a.mueller\\eclipse\\svn\\cdmlib-trunk\\cdmlib-remote-webapp\\src\\test\\resources\\h2";
|
113
|
// username = "sa";
|
114
|
// dataSource = CdmDataSource.NewH2EmbeddedInstance("cdm", username, "", path);
|
115
|
|
116
|
// dataSource = CdmDataSource.NewH2EmbeddedInstance(database, username, "sa");
|
117
|
|
118
|
|
119
|
// server = "160.45.63.201";
|
120
|
// database = "cdm_integration_cichorieae";
|
121
|
// username = "edit";
|
122
|
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
|
123
|
|
124
|
|
125
|
// try {
|
126
|
// CdmUpdater updater = new CdmUpdater();
|
127
|
// if (schema == DbSchemaValidation.VALIDATE){
|
128
|
// updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
|
129
|
// }
|
130
|
// } catch (Exception e) {
|
131
|
// e.printStackTrace();
|
132
|
// }
|
133
|
|
134
|
//CdmPersistentDataSource.save(dataSource.getName(), dataSource);
|
135
|
CdmApplicationController appCtr;
|
136
|
appCtr = CdmApplicationController.NewInstance(dataSource, schema);
|
137
|
// Classification classification = appCtr.getClassificationService().list(null, null, null, null, null).get(0);
|
138
|
// logger.warn(classification.getMicroReference());
|
139
|
// logger.warn(classification.getName());
|
140
|
|
141
|
// TransactionStatus tx = appCtr.startTransaction();
|
142
|
|
143
|
// testGroupedTaxa(appCtr);
|
144
|
|
145
|
|
146
|
// int n = appCtr.getAgentService().count(null);
|
147
|
// logger.warn("End adding " + n + " persons");
|
148
|
|
149
|
// appCtr.getCommonService().createFullSampleData();
|
150
|
|
151
|
// ValidationManager valMan = (ValidationManager)appCtr.getBean("validationManager");
|
152
|
// valMan.registerValidationListeners();
|
153
|
|
154
|
// State state = State.NewInstance();
|
155
|
// Taxon taxon = Taxon.NewInstance(null, null);
|
156
|
// TaxonDescription desc = TaxonDescription.NewInstance(taxon);
|
157
|
//// CategoricalData catData = CategoricalData.NewInstance(state, Feature.HABITAT());
|
158
|
// QuantitativeData quantData = QuantitativeData.NewInstance(Feature.ANATOMY());
|
159
|
// StatisticalMeasurementValue statisticalValue = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.AVERAGE(), 2);
|
160
|
// quantData.addStatisticalValue(statisticalValue);
|
161
|
// desc.addElement(quantData);
|
162
|
|
163
|
// appCtr.getTermService().saveOrUpdate(state);
|
164
|
//
|
165
|
// appCtr.getTaxonService().save(taxon);
|
166
|
|
167
|
// insertSomeData(appCtr);
|
168
|
// deleteHighLevelNode(appCtr); //->problem with Duplicate Key in Classification_TaxonNode
|
169
|
appCtr.close();
|
170
|
System.exit(0);
|
171
|
}
|
172
|
|
173
|
|
174
|
/**
|
175
|
* @param appCtr
|
176
|
*/
|
177
|
private void testGroupedTaxa(CdmApplicationController appCtr) {
|
178
|
UUID classificationUuid = UUID.fromString("91231ebf-1c7a-47b9-a56c-b45b33137244");
|
179
|
UUID taxonUuid1 = UUID.fromString("3bae1c86-1235-4e2e-be63-c7f8c4410527");
|
180
|
UUID taxonUuid2 = UUID.fromString("235d3872-defe-4b92-bf2f-75a7c91510de");
|
181
|
List<UUID> taxonUuids = Arrays.asList(new UUID[]{taxonUuid1, taxonUuid2});
|
182
|
Rank maxRank = DefinedTermBase.getTermByClassAndUUID(Rank.class, UUID.fromString("af5f2481-3192-403f-ae65-7c957a0f02b6"));
|
183
|
Rank minRank = DefinedTermBase.getTermByClassAndUUID(Rank.class, UUID.fromString("78786e16-2a70-48af-a608-494023b91904"));
|
184
|
List<GroupedTaxonDTO> groupedTaxa = appCtr.getClassificationService().groupTaxaByHigherTaxon(taxonUuids, classificationUuid, minRank, maxRank);
|
185
|
System.out.println(groupedTaxa);
|
186
|
}
|
187
|
|
188
|
|
189
|
private void addPerson(CdmApplicationController appCtr) {
|
190
|
TransactionStatus tx = appCtr.startTransaction();
|
191
|
appCtr.getAgentService().save(Person.NewInstance());
|
192
|
appCtr.commitTransaction(tx);
|
193
|
}
|
194
|
|
195
|
|
196
|
private void deleteHighLevelNode(CdmApplicationController appCtr) {
|
197
|
TransactionStatus tx = appCtr.startTransaction();
|
198
|
ITaxonNodeService service = appCtr.getTaxonNodeService();
|
199
|
TaxonNode node = service.find(60554);
|
200
|
// service.delete(node);
|
201
|
ITaxonService taxonService = appCtr.getTaxonService();
|
202
|
Taxon taxon = node.getTaxon();
|
203
|
//try {
|
204
|
taxonService.deleteTaxon(taxon.getUuid(), new TaxonDeletionConfigurator(), node.getClassification().getUuid());
|
205
|
|
206
|
/*} catch (DataChangeNoRollbackException e) {
|
207
|
e.printStackTrace();
|
208
|
}*/
|
209
|
try {
|
210
|
appCtr.commitTransaction(tx);
|
211
|
} catch (Exception e) {
|
212
|
// TODO Auto-generated catch block
|
213
|
e.printStackTrace();
|
214
|
}
|
215
|
TaxonNode node2 = service.find(60554);
|
216
|
|
217
|
|
218
|
}
|
219
|
|
220
|
private void insertSomeData(CdmApplicationController appCtr) {
|
221
|
Classification cl = Classification.NewInstance("myClass");
|
222
|
TaxonNode node1 = cl.addChildTaxon(Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(null), null), null, null);
|
223
|
appCtr.getClassificationService().save(cl);
|
224
|
|
225
|
Taxon t2 = Taxon.NewInstance(null, null);
|
226
|
t2.setTitleCache("Taxon2", true);
|
227
|
TaxonNode node2 = node1.addChildTaxon(t2, null, null);
|
228
|
|
229
|
Taxon t3 = Taxon.NewInstance(null, null);
|
230
|
t3.setTitleCache("Taxon3", true);
|
231
|
TaxonNode node3 = node1.addChildTaxon(t3, 0, null, null);
|
232
|
|
233
|
appCtr.getTaxonNodeService().saveOrUpdate(node1);
|
234
|
|
235
|
cl.addChildNode(node3, 0, null, null);
|
236
|
appCtr.getTaxonNodeService().saveOrUpdate(node3);
|
237
|
appCtr.getClassificationService().saveOrUpdate(cl);
|
238
|
|
239
|
FeatureTree ft1 = FeatureTree.NewInstance();
|
240
|
FeatureNode fn1 = FeatureNode.NewInstance(null);
|
241
|
ft1.getRoot().addChild(fn1);
|
242
|
appCtr.getFeatureNodeService().save(fn1);
|
243
|
|
244
|
FeatureNode fn2 = FeatureNode.NewInstance(null);
|
245
|
fn1.addChild(fn2);
|
246
|
|
247
|
FeatureNode fn3 = FeatureNode.NewInstance(null);
|
248
|
fn1.addChild(fn2, 0);
|
249
|
|
250
|
appCtr.getFeatureNodeService().saveOrUpdate(fn1);
|
251
|
|
252
|
ft1.getRoot().addChild(fn3, 0);
|
253
|
appCtr.getFeatureNodeService().saveOrUpdate(fn3);
|
254
|
appCtr.getFeatureTreeService().saveOrUpdate(ft1);
|
255
|
}
|
256
|
|
257
|
private void testDatabaseChange() throws DataSourceNotFoundException{
|
258
|
CdmApplicationController appCtr;
|
259
|
appCtr = CdmApplicationController.NewInstance();
|
260
|
|
261
|
// DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
|
262
|
// String server = "192.168.2.10";
|
263
|
// String database = "cdm_test_andreas";
|
264
|
// String user = "edit";
|
265
|
// String pwd = "wp5";
|
266
|
//
|
267
|
DatabaseTypeEnum dbType = DatabaseTypeEnum.SqlServer2005;
|
268
|
String server = "LAPTOPHP";
|
269
|
String database = "cdmTest";
|
270
|
String username = "edit";
|
271
|
String password = "";
|
272
|
|
273
|
ICdmDataSource dataSource = CdmDataSource.NewInstance(DatabaseTypeEnum.SqlServer2005, "LAPTOPHP", "cdmTest", DatabaseTypeEnum.SqlServer2005.getDefaultPort(), "edit", "");
|
274
|
|
275
|
appCtr.getDatabaseService().saveDataSource("testSqlServer", dataSource);
|
276
|
try {
|
277
|
appCtr.getDatabaseService().connectToDatabase(dbType, server, database, username, password);
|
278
|
} catch (TermNotFoundException e) {
|
279
|
// TODO Auto-generated catch block
|
280
|
e.printStackTrace();
|
281
|
}
|
282
|
|
283
|
appCtr.close();
|
284
|
}
|
285
|
|
286
|
private void testSqlServer2005(){
|
287
|
DatabaseTypeEnum databaseTypeEnum = DatabaseTypeEnum.SqlServer2005;
|
288
|
String server = "LAPTOPHP";
|
289
|
String database = "cdmTest";
|
290
|
String username = "edit";
|
291
|
String password = "";
|
292
|
|
293
|
ICdmDataSource dataSource = CdmDataSource.NewInstance(databaseTypeEnum, server, database, databaseTypeEnum.getDefaultPort(), username, password);
|
294
|
|
295
|
CdmPersistentDataSource ds = CdmPersistentDataSource.save("testSqlServer", dataSource);
|
296
|
|
297
|
CdmApplicationController appCtr = CdmApplicationController.NewInstance(ds);
|
298
|
Person agent = Person.NewInstance();
|
299
|
appCtr.getAgentService().save(agent);
|
300
|
TaxonName tn = TaxonNameFactory.NewBotanicalInstance(null);
|
301
|
appCtr.getNameService().save(tn);
|
302
|
appCtr.close();
|
303
|
|
304
|
}
|
305
|
|
306
|
|
307
|
private void testLocalHsql(){
|
308
|
CdmApplicationController appCtr = null;
|
309
|
try {
|
310
|
CdmPersistentDataSource ds = CdmPersistentDataSource.NewLocalHsqlInstance();
|
311
|
appCtr = CdmApplicationController.NewInstance(ds);
|
312
|
List<?> l = appCtr.getNameService().list(null,5, 1,null,null);
|
313
|
System.out.println(l);
|
314
|
//Agent agent = new Agent();
|
315
|
//appCtr.getAgentService().saveAgent(agent);
|
316
|
appCtr.close();
|
317
|
} catch (RuntimeException e) {
|
318
|
logger.error("Runtime Exception");
|
319
|
e.printStackTrace();
|
320
|
if (appCtr != null){
|
321
|
appCtr.close();
|
322
|
}
|
323
|
|
324
|
} catch (DataSourceNotFoundException e) {
|
325
|
logger.error("Runtime Exception");
|
326
|
e.printStackTrace();
|
327
|
}
|
328
|
}
|
329
|
|
330
|
private void testLocalH2(){
|
331
|
|
332
|
DbSchemaValidation validation = DbSchemaValidation.CREATE;
|
333
|
ICdmDataSource ds =
|
334
|
CdmDataSource.NewH2EmbeddedInstance("cdm", "sa", "", null);
|
335
|
// ds =
|
336
|
// CdmPersistentDataSource.NewInstance("localH2");
|
337
|
CdmApplicationController appCtr = CdmApplicationController.NewInstance(ds, validation);
|
338
|
|
339
|
boolean exists = appCtr.getUserService().userExists("admin");
|
340
|
try {
|
341
|
IBotanicalName name = TaxonNameFactory.NewBotanicalInstance(null);
|
342
|
String nameCache = "testName";
|
343
|
name.setNameCache(nameCache);
|
344
|
name.setTitleCache(nameCache, true);
|
345
|
Reference ref = ReferenceFactory.newGeneric();
|
346
|
ref.setTitleCache("mySec", true);
|
347
|
Taxon taxon = Taxon.NewInstance(name, ref);
|
348
|
TaxonDescription description = TaxonDescription.NewInstance();
|
349
|
taxon.addDescription(description);
|
350
|
NamedArea area1 = appCtr.getTermService().getAreaByTdwgAbbreviation("GER");
|
351
|
Distribution distribution = Distribution.NewInstance(area1, PresenceAbsenceTerm.PRESENT());
|
352
|
description.addElement(distribution);
|
353
|
|
354
|
List<Distribution> distrList = new ArrayList<Distribution>();
|
355
|
distrList.add(distribution);
|
356
|
List<NamedArea> areaList = new ArrayList<NamedArea>();
|
357
|
areaList.add(area1);
|
358
|
|
359
|
// distribution.getInDescription().get
|
360
|
appCtr.getTaxonService().save(taxon);
|
361
|
|
362
|
System.out.println(taxon.getDescriptions().size());
|
363
|
|
364
|
TransactionStatus txStatus = appCtr.startTransaction();
|
365
|
|
366
|
Session session = appCtr.getSessionFactory().getCurrentSession();
|
367
|
|
368
|
//String hqlQuery = "from DescriptionBase d join d.elements as e "
|
369
|
// String hqlQuery = "from Taxon t join t.descriptions as d "+
|
370
|
// " inner join d.elements e on e member of d "
|
371
|
// +
|
372
|
// "";//" where e.area = :namedArea " ;
|
373
|
String hqlQuery = "Select t from Distribution e join e.inDescription d join d.taxon t join t.name n "+
|
374
|
" WHERE e.area in (:namedArea) AND n.nameCache = :nameCache ";
|
375
|
Query query = session.createQuery(hqlQuery);
|
376
|
|
377
|
//query.setEntity("namedArea", area1);
|
378
|
query.setParameter("nameCache", nameCache);
|
379
|
query.setParameterList("namedArea", areaList);
|
380
|
List resultList = query.list();
|
381
|
//List list = appCtr.getCommonService().getHqlResult(hqlQuery);
|
382
|
|
383
|
for (Object o:resultList){
|
384
|
System.out.println(o);
|
385
|
}
|
386
|
appCtr.commitTransaction(txStatus);
|
387
|
|
388
|
//System.out.println(l);
|
389
|
//Agent agent = new Agent();
|
390
|
//appCtr.getAgentService().saveAgent(agent);
|
391
|
appCtr.close();
|
392
|
} catch (RuntimeException e) {
|
393
|
logger.error("Runtime Exception");
|
394
|
e.printStackTrace();
|
395
|
appCtr.close();
|
396
|
|
397
|
}
|
398
|
}
|
399
|
|
400
|
private boolean testWritableResourceDirectory() throws IOException{
|
401
|
CdmApplicationUtils.getWritableResourceDir();
|
402
|
return true;
|
403
|
}
|
404
|
|
405
|
private boolean testH2(){
|
406
|
// testLocalH2();
|
407
|
// if (true)return true;
|
408
|
|
409
|
DbSchemaValidation validation = DbSchemaValidation.CREATE;
|
410
|
ICdmDataSource ds =
|
411
|
CdmDataSource.NewH2EmbeddedInstance("cdm", "sa", "", null);
|
412
|
//CdmDataSource.NewH2EmbeddedInstance("cdm", "sa", "");
|
413
|
// ds =
|
414
|
// CdmPersistentDataSource.NewInstance("localH2");
|
415
|
CdmApplicationController appCtr = CdmApplicationController.NewInstance(ds, validation);
|
416
|
try {
|
417
|
TaxonName botName1 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
418
|
TaxonName botName2 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
419
|
IBotanicalName hybridName = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
420
|
botName1.addRelationshipToName(botName2, NameRelationshipType.ORTHOGRAPHIC_VARIANT(), null);
|
421
|
UUID uuid1 = botName1.getUuid();
|
422
|
UUID uuid2 = botName2.getUuid();
|
423
|
try {
|
424
|
Logger loggerTrace = Logger.getLogger("org.hibernate.type");
|
425
|
loggerTrace.setLevel(Level.TRACE);
|
426
|
System.out.println(logger.getName());
|
427
|
|
428
|
appCtr.getNameService().save(botName1);
|
429
|
ResultSet rs = ds.executeQuery("Select count(*) as n FROM NameRelationship");
|
430
|
rs.next();
|
431
|
int c = rs.getInt("n");
|
432
|
System.out.println("Begin :" + c);
|
433
|
|
434
|
botName1.removeRelationToTaxonName(botName2);
|
435
|
botName1.setSpecificEpithet("DELETED");
|
436
|
botName2.addHybridParent(hybridName, HybridRelationshipType.FIRST_PARENT(), null);
|
437
|
|
438
|
TransactionStatus tx = appCtr.startTransaction();
|
439
|
appCtr.getNameService().saveOrUpdate(botName2);
|
440
|
rs = ds.executeQuery("Select count(*) as n FROM NameRelationship");
|
441
|
rs.next();
|
442
|
c = rs.getInt("n");
|
443
|
System.out.println("End: " + c);
|
444
|
|
445
|
appCtr.commitTransaction(tx);
|
446
|
|
447
|
appCtr.getNameService().saveOrUpdate(botName1);
|
448
|
|
449
|
rs = ds.executeQuery("Select count(*) as n FROM NameRelationship");
|
450
|
rs.next();
|
451
|
c = rs.getInt("n");
|
452
|
System.out.println("End: " + c);
|
453
|
|
454
|
} catch (SQLException e) {
|
455
|
// TODO Auto-generated catch block
|
456
|
e.printStackTrace();
|
457
|
}
|
458
|
|
459
|
|
460
|
//Agent agent = new Agent();
|
461
|
//appCtr.getAgentService().saveAgent(agent);
|
462
|
appCtr.close();
|
463
|
return true;
|
464
|
} catch (RuntimeException e) {
|
465
|
logger.error("Runtime Exception");
|
466
|
e.printStackTrace();
|
467
|
appCtr.close();
|
468
|
|
469
|
}
|
470
|
return false;
|
471
|
}
|
472
|
|
473
|
private void test(){
|
474
|
System.out.println("Start Datasource");
|
475
|
testNewConfigControler();
|
476
|
//testDatabaseChange();
|
477
|
|
478
|
//testSqlServer();
|
479
|
|
480
|
//CdmUtils.findLibrary(au.com.bytecode.opencsv.CSVReader.class);
|
481
|
//testPostgreServer();
|
482
|
//testLocalHsql();
|
483
|
//testLocalH2();
|
484
|
//testWritableResourceDirectory();
|
485
|
// testH2();
|
486
|
System.out.println("\nEnd Datasource");
|
487
|
}
|
488
|
|
489
|
/**
|
490
|
* @param args
|
491
|
*/
|
492
|
public static void main(String[] args) {
|
493
|
Datasource cc = new Datasource();
|
494
|
cc.test();
|
495
|
}
|
496
|
|
497
|
}
|