Finding out if database supports a transaction isolation level

You can get an instance of DatabaseMetaData by invoking getMetaData on a connection. Then you can query whether or not your db supports a certain isolation level by invoking supportsTransactionIsolationLevel.

Main.java:

import java.util.*;
import java.sql.*;
  
public class Main {
   public static void main(String []args) throws Exception {
      try {
         Class.forName("org.gjt.mm.mysql.Driver").newInstance();
         Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.0.1/esus", 
                                                       "joris",
                                                       "mypass");
 
         DatabaseMetaData dbMeta = conn.getMetaData(); 
         System.out.println(dbMeta.supportsTransactionIsolationLevel(
                                               Connection.TRANSACTION_READ_COMMITTED));
         System.out.println(dbMeta.supportsTransactionIsolationLevel(
                                               Connection.TRANSACTION_READ_UNCOMMITTED));
         System.out.println(dbMeta.supportsTransactionIsolationLevel(
                                               Connection.TRANSACTION_REPEATABLE_READ));
         System.out.println(dbMeta.supportsTransactionIsolationLevel(
                                               Connection.TRANSACTION_SERIALIZABLE));
      }
      catch(Exception e) {
         e.printStackTrace();
      }
   } 
}