public static void openFile ( Connection connection , String fileName , String tableName ) throws SQLException { String ext = fileName . substring ( fileName . lastIndexOf ( ' ' ) + 1 , fileName . length ( ) ) ; final boolean isH2 = JDBCUtilities . isH2DataBase ( connection . getMetaData ( ) ) ; for ( DriverDef driverDef : DRIVERS ) { if ( driverDef . getFileExt ( ) . equalsIgnoreCase ( ext ) ) { try ( Statement st = connection . createStatement ( ) ) { st . execute ( String . format ( "CREATE TABLE %s COMMENT %s ENGINE %s WITH %s" , TableLocation . parse ( tableName , isH2 ) . toString ( isH2 ) , StringUtils . quoteStringSQL ( fileName ) , StringUtils . quoteJavaString ( driverDef . getClassName ( ) ) , StringUtils . quoteJavaString ( fileName ) ) ) ; } return ; } } throw new SQLException ( "No driver is available to open the " + ext + " file format" ) ; }
Create a new table