I want to write a SpringBatch Tasklet, that automatically activates or de-activates all indexes for a given database table. The code needs to work independantly of the DBMS
Below code is used to retrieve the INDEX_NAME From the DATABASE.
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) throws Exception {
Connection conn = getOracleConnection(); //Based on the database corresponding method should be called
List schemaList=new ArrayList();
List catalogList=new ArrayList();
List indexs=new ArrayList();
String dbIndexName=null;
ResultSet rs=null;
System.out.println("Got Connection.");
try {
DatabaseMetaData metaData = conn.getMetaData();
ResultSet schemas = metaData.getSchemas();
ResultSet catalog = metaData.getCatalogs();
while (schemas.next()) {
String tableSchema = schemas.getString(1);
schemaList.add(tableSchema);
}
while (catalog.next()) {
String allCatalog = catalog.getString(1);
catalogList.add(allCatalog);
}
for(int i=0;i
}