public int addServerRedirect ( String region , String srcUrl , String destUrl , String hostHeader , int profileId , int groupId ) throws Exception { int serverId = - 1 ; PreparedStatement statement = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { statement = sqlConnection . prepareStatement ( "INSERT INTO " + Constants . DB_TABLE_SERVERS + "(" + Constants . SERVER_REDIRECT_REGION + "," + Constants . SERVER_REDIRECT_SRC_URL + "," + Constants . SERVER_REDIRECT_DEST_URL + "," + Constants . SERVER_REDIRECT_HOST_HEADER + "," + Constants . SERVER_REDIRECT_PROFILE_ID + "," + Constants . SERVER_REDIRECT_GROUP_ID + ")" + " VALUES (?, ?, ?, ?, ?, ?);" , PreparedStatement . RETURN_GENERATED_KEYS ) ; statement . setString ( 1 , region ) ; statement . setString ( 2 , srcUrl ) ; statement . setString ( 3 , destUrl ) ; statement . setString ( 4 , hostHeader ) ; statement . setInt ( 5 , profileId ) ; statement . setInt ( 6 , groupId ) ; statement . executeUpdate ( ) ; results = statement . getGeneratedKeys ( ) ; if ( results . next ( ) ) { serverId = results . getInt ( 1 ) ; } else { // something went wrong throw new Exception ( "Could not add path" ) ; } } catch ( SQLException e ) { e . printStackTrace ( ) ; } finally { try { if ( results != null ) { results . close ( ) ; } } catch ( Exception e ) { } try { if ( statement != null ) { statement . close ( ) ; } } catch ( Exception e ) { } } return serverId ; }
Add server redirect to a profile