Rule Definition
One main source of data corruption within applications comes from lack of compliance to data modification rules defined for an application. These rules are usually related to the use of specific procedures for update/insert/delete, a specific API or a data layer that is fully tested to maintain data integrity. The creation of new, different update/insert/delete procedures and functions that do not make use the existing tested code is at origin of many data corruption cases.
Violation Code Sample
import java.sql.*;
public class TestUpdate1 {
public static void main(java.lang.String[] args) {
String query = "UPDATE books SET books.title = 'MyTest' WHERE books.id=1";
try {
Statement stmt = con.createStatement();
results = stmt.executeQuery(requete);
} catch (SQLException e) {
// ...
}
}
}
// ... X classes update the same table
public class TestUpdateX {
public static void main(java.lang.String[] args) {
String query = "UPDATE books SET books.title = 'MyTestX' WHERE books.id=X";
try {
Statement stmt = con.createStatement();
results = stmt.executeQuery(requete);
} catch (SQLException e) {
// ...
}
}
}
Fixed Code Sample
import java.sql.*;
// less than X classes update the same table
public class TestUpdate {
public static void main(java.lang.String[] args) {
String query = "DELETE FROM books WHERE books.id=1";
try {
Statement stmt = con.createStatement();
results = stmt.executeQuery(requete);
} catch (SQLException e) {
// ...
}
}
}
Related Technologies
DB2 Server
Forms
PL/SQL
Microsoft T-SQL
Sybase T-SQL
DB2 z/OS
SQLScript
Technical Criterion
Architecture - Multi-Layers and Data Access
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.