2017-01-10 92 views
1

如何從PreparedStatement獲得sessionId? 在調試模式下,我可以這樣如何從`PreparedStatement`獲取sessionId?

((T4CConnection) ((T4CPreparedStatement) ((OraclePreparedStatementWrapper) ps).preparedStatement).connection).sessionId 

,但我怎麼能得到這個sessionId在我的課?

回答

1
Field sessionIdField = ps.getConnection().getClass().getDeclaredField("sessionId"); 
        Field serialNumberField = ps.getConnection().getClass().getDeclaredField("serialNumber"); 
        sessionIdField.setAccessible(true); 
        serialNumberField.setAccessible(true); 
        Object sessionId = sessionIdField.get(ps.getConnection()); 
        Object serialNumber = serialNumberField.get(ps.getConnection()); 
相關問題