@@ -131,7 +131,7 @@ String createDBLinks(DataSource orderpdbDataSource, DataSource inventorypdbDataS
131
131
createDBLink (connection , "ORDERPDB_CRED" , "inventorytoorder" , inventoryToOrderLinkName );
132
132
}
133
133
verifyDBLinks (orderpdbDataSource , inventorypdbDataSource );
134
- return "DBLinks created and verified successfully" ;
134
+ return "DBLinks created. Verification:" + verifyDBLinks ( orderpdbDataSource , inventorypdbDataSource ) ;
135
135
}
136
136
137
137
private void createDBLink (Connection connection , String credName , String createlink , String linkname ) throws SQLException {
@@ -168,35 +168,51 @@ private void createDBLink(Connection connection, String credName, String createl
168
168
System .out .println (" CREATE_DATABASE_LINK " + linkname + " successful," );
169
169
}
170
170
171
- String verifyDBLinks (DataSource orderpdbDataSource , DataSource inventorypdbDataSource ) throws SQLException {
171
+ String verifyDBLinks (DataSource orderpdbDataSource , DataSource inventorypdbDataSource ) {
172
+ try (Connection inventoryconnection = inventorypdbDataSource .getConnection (inventoryuser , inventorypw )) {
173
+ System .out .println ("Create templinktest table on inventorydb..." );
174
+ inventoryconnection .createStatement ().execute ("create table templinktabledoninventorydb (id varchar(32))" );
175
+ System .out .println ("Create templinktest table on inventorydb success" );
176
+ } catch (SQLException ex ) {
177
+ ex .printStackTrace ();
178
+ }
179
+ try (Connection orderconnection = orderpdbDataSource .getConnection (orderuser , orderpw )) {
180
+ System .out .println ("Create templinktest table on orderdb..." );
181
+ orderconnection .createStatement ().execute ("create table templinktableonorderdb (id varchar(32))" );
182
+ System .out .println ("Create templinktest table on orderdb success" );
183
+ } catch (SQLException ex ) {
184
+ ex .printStackTrace ();
185
+ }
186
+
172
187
String returnString = "" ;
173
188
returnString += "orderuser select on inventorypdb using link..." ;
174
189
try (Connection orderconnection = orderpdbDataSource .getConnection (orderuser , orderpw )) {
175
- System .out .println ("verifyDBLinks orderconnection:" + orderconnection );
176
- orderconnection .createStatement ().execute ("create table templinktest (id varchar(32))" );
177
- System .out .println ("verifyDBLinks temp table created on order" );
190
+ System .out .println ("verifyDBLinks orderconnection to inventorydb :" + orderToInventoryLinkName );
191
+ // orderconnection.createStatement().execute("create table templinktest (id varchar(32))");
192
+ // System.out.println("verifyDBLinks temp table created on order");
178
193
// verify orderuser select on inventorypdb using link...
179
- orderconnection .createStatement ().execute ("select count(*) from inventoryuser.templinktest @" + orderToInventoryLinkName );
194
+ orderconnection .createStatement ().execute ("select count(*) from inventoryuser.templinktabledoninventorydb @" + orderToInventoryLinkName );
180
195
System .out .println ("verifyDBLinks select on inventoryuser.templinktest" );
181
- orderconnection .createStatement ().execute ("drop table templinktest" );
196
+ // orderconnection.createStatement().execute("drop table templinktest");
182
197
returnString += "success" ;
183
198
} catch (SQLException ex ) {
184
199
returnString += ex ;
185
200
}
186
201
returnString += "inventoryuser select on orderpdb using link..." ;
187
202
try (Connection inventoryconnection = inventorypdbDataSource .getConnection (inventoryuser , inventorypw )) {
188
- System .out .println ("verifyDBLinks inventoryconnection:" + inventoryconnection );
189
- inventoryconnection .createStatement ().execute ("create table templinktest (id varchar(32))" );
190
- System .out .println ("verifyDBLinks temp table created on inventory" );
203
+ System .out .println ("verifyDBLinks inventoryconnection to orderdb :" + inventoryToOrderLinkName );
204
+ // inventoryconnection.createStatement().execute("create table templinktest (id varchar(32))");
205
+ // System.out.println("verifyDBLinks temp table created on inventory");
191
206
// verify inventoryuser select on orderpdb using link ...
192
- inventoryconnection .createStatement ().execute ("select count(*) from orderuser.templinktest @" + inventoryToOrderLinkName );
193
- System .out .println ("verifyDBLinks select on orderuser.templinktest " );
194
- inventoryconnection .createStatement ().execute ("drop table templinktest" );
207
+ inventoryconnection .createStatement ().execute ("select count(*) from orderuser.templinktableonorderdb @" + inventoryToOrderLinkName );
208
+ System .out .println ("verifyDBLinks select on orderuser.templinktableonorderdb " );
209
+ // inventoryconnection.createStatement().execute("drop table templinktest");
195
210
returnString += "success" ;
196
211
} catch (SQLException ex ) {
197
212
returnString += ex ;
198
213
}
199
214
return returnString ;
215
+ //todo drop templinktabledoninventorydb and templinktableonorderdb to cleanup
200
216
}
201
217
202
218
public String setupTablesQueuesAndPropagation (DataSource orderpdbDataSource , DataSource inventorypdbDataSource ,
@@ -245,10 +261,10 @@ private String setupTablesQueuesAndPropagation(
245
261
String linkName , boolean isTest ) {
246
262
String returnString = "sourcepdbDataSource = [" + sourcepdbDataSource + "], " +
247
263
"targetpdbDataSource = [" + targetpdbDataSource + "], " +
248
- "sourcename = [" + sourcename + "], sourcepw = [" + sourcepw + "], " +
264
+ "sourcename = [" + sourcename + "], " +
249
265
"sourcequeuename = [" + sourcequeuename + "], " +
250
266
"sourcequeuetable = [" + sourcequeuetable + "], targetuser = [" + targetuser + "], " +
251
- "targetpw = [" + targetpw + "], linkName = [" + linkName + "] isTest = " + isTest ;
267
+ "linkName = [" + linkName + "] isTest = " + isTest ;
252
268
System .out .println (returnString );
253
269
try {
254
270
TopicConnectionFactory tcfact = AQjmsFactory .getTopicConnectionFactory (sourcepdbDataSource );
0 commit comments