@@ -131,7 +131,7 @@ String createDBLinks(DataSource orderpdbDataSource, DataSource inventorypdbDataS
131131 createDBLink (connection , "ORDERPDB_CRED" , "inventorytoorder" , inventoryToOrderLinkName );
132132 }
133133 verifyDBLinks (orderpdbDataSource , inventorypdbDataSource );
134- return "DBLinks created and verified successfully" ;
134+ return "DBLinks created. Verification:" + verifyDBLinks ( orderpdbDataSource , inventorypdbDataSource ) ;
135135 }
136136
137137 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
168168 System .out .println (" CREATE_DATABASE_LINK " + linkname + " successful," );
169169 }
170170
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+
172187 String returnString = "" ;
173188 returnString += "orderuser select on inventorypdb using link..." ;
174189 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");
178193 // 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 );
180195 System .out .println ("verifyDBLinks select on inventoryuser.templinktest" );
181- orderconnection .createStatement ().execute ("drop table templinktest" );
196+ // orderconnection.createStatement().execute("drop table templinktest");
182197 returnString += "success" ;
183198 } catch (SQLException ex ) {
184199 returnString += ex ;
185200 }
186201 returnString += "inventoryuser select on orderpdb using link..." ;
187202 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");
191206 // 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");
195210 returnString += "success" ;
196211 } catch (SQLException ex ) {
197212 returnString += ex ;
198213 }
199214 return returnString ;
215+ //todo drop templinktabledoninventorydb and templinktableonorderdb to cleanup
200216 }
201217
202218 public String setupTablesQueuesAndPropagation (DataSource orderpdbDataSource , DataSource inventorypdbDataSource ,
@@ -245,10 +261,10 @@ private String setupTablesQueuesAndPropagation(
245261 String linkName , boolean isTest ) {
246262 String returnString = "sourcepdbDataSource = [" + sourcepdbDataSource + "], " +
247263 "targetpdbDataSource = [" + targetpdbDataSource + "], " +
248- "sourcename = [" + sourcename + "], sourcepw = [" + sourcepw + "], " +
264+ "sourcename = [" + sourcename + "], " +
249265 "sourcequeuename = [" + sourcequeuename + "], " +
250266 "sourcequeuetable = [" + sourcequeuetable + "], targetuser = [" + targetuser + "], " +
251- "targetpw = [" + targetpw + "], linkName = [" + linkName + "] isTest = " + isTest ;
267+ "linkName = [" + linkName + "] isTest = " + isTest ;
252268 System .out .println (returnString );
253269 try {
254270 TopicConnectionFactory tcfact = AQjmsFactory .getTopicConnectionFactory (sourcepdbDataSource );
0 commit comments