I am facing the same issue under tMySQLInput and the settings revert automatically.
While you are on the Dynamic Settings tab the Code works fine. For Example : This works and picks the connection from Global Map.
" + globalMap.get("conn2") + "
Associated Java Code also seems fine.
java.sql.Connection conn_tMysqlInput_1 = null;
conn_tMysqlInput_1 = (java.sql.Connection) globalMap.get("conn_" + globalMap.get("conn2") + "");
But as soon as you switch Tab, the value in dynamic tab reverts to tMysqlConnection_1 and also the java code.
As code, you can input a context variable or a piece of Java code.
Its working as expected in Version: 5.6.1
Build id: V5.6.1_20141207_1530