我正在尝试通过SSH隧道连接到EC2实例上的RDS数据库,以进行调试。我尝试通过SSH隧道进入EC2实例,然后端口转发到RDS数据库。以下是我的代码。
final int localPort = 9999;
// Create BaiscDataSource.
final String databaseURL = "jdbc:mysql://localhost:" + localPort + "/database";
// SSH Tunnel.
final JSch jsch = new JSch();
jsch.addIdentity(sshKeyPath);
this.session = jsch.getSession(ec2Username, ec2Host, 22);
this.session.setTimeout(0);
this.session.setConfig("StrictHostKeyChecking", "no");
this.session.connect();
this.session.setPortForwardingL(localPort, rdsHost, 3306);
请帮忙!
编辑人:looply_dev 于2012年10月2日下午4:17编辑
localhost:9999
不行吗? - favoretti