Database Exceptions
The code that runs the database operation is generated within a try/catch block and catches a DBServiceException. The business service creates a new E1Message that returns database errors for data dictionary error item 005FIS. When you use the business service foundation code for E1Message, you can create a new message and use the sLineSeparator constant to take advantage of text substitution within the E1Message. The following sample code shows substituting the view name for one parameter and the exception text for the other. Without text substitution, the E1 DD Error Item Description reads:
Table - &1,&2
This code sample shows using text substitution:
"Exception in thread "main" oracle.e1.bssvfoundation.exception.BusinessServiceException: Error: Table/View - F0101Z2 Error during database operation: [DUPLICATE_KEY_ERROR] Duplicate key error obtained for table F0101Z2., at oracle.e1.bssv.JPR01002.AddressBook StagingManager.insertAddressBookStaging (AddressBookStagingManager.java:78) at oracle.e1.bssv.JPR01002.AddressBookStagingManager.insertAddress BookStaging(AddressBookStagingManager.java:39) at oracle.e1.bssv.JTR87011.AddressBookStagingTest.testInsertAddress BookZTable1Record(AddressBookStagingTest.java:71) at oracle.e1.bssv.JTR87011.AddressBookStagingTest.main(AddressBook StagingTest.java:110"
This sample shows the code that is generated by business service foundation:
private static final String QUERY_VIEW = "V0101XPI"; ... try { //get dbService from context IDBService dbService = context.getDBService(); //execute db select operation resultSet = dbService.BSSVDBSelect(context, connection, "V0101XPI", IDBService.DB_BSVW, selectDistinct, maxReturnedRows, selectFields, sortOrder, whereClause); } catch (DBServiceException e) { //take some action in response to the database exception returnMessages.addMessage(new E1Message(context, "005FIS", QUERY_VIEW + E1Message.sLineSeparator+e.getMessage())); }