* @see com.adito.tunnels.TunnelDatabase#createTunnel(int, java.lang.String, java.lang.String, int, boolean, java.lang.String, java.lang.String, int, com.adito.boot.HostService, java.lang.String)
*/
public Tunnel createTunnel(int realmID, String name, String description, int type, boolean autoStart, String transport, String username,
int sourcePort, HostService destination, String sourceInterface) throws Exception {
JDBCPreparedStatement ps2 = db.getStatement("createTunnel.insert");
try {
ps2.setString(1, name);
ps2.setString(2, description);
ps2.setInt(3, type);
ps2.setInt(4, autoStart ? 1 : 0);
ps2.setString(5, transport);
ps2.setString(6, username == null ? "" : username);
ps2.setInt(7, sourcePort);
ps2.setInt(8, destination.getPort());
ps2.setString(9, destination.getHost());
ps2.setString(10, sourceInterface);
Calendar now = Calendar.getInstance();
ps2.setString(11, db.formatTimestamp(now));
ps2.setString(12, db.formatTimestamp(now));
ps2.setInt(13, realmID);
ps2.execute();
return new DefaultTunnel(realmID, name, description, db.getLastInsertId(ps2, "createTunnel.lastInsertId"), type, autoStart,
transport, username, sourcePort, destination, sourceInterface, now, now);
} finally {
ps2.releasePreparedStatement();
}
}