Hello! I have been playing around with Jsch to establish an SSH
connection to my remote server. I have followed numerous tutorials but
seem to be banging my head against the wall.

I am using Eclipse Juno & Windows 7 64-bit.

I am trying to connect to my web server, and access MySQL through an
SSH tunnel. The MySQL application lives in the web-server.

Web Server: web1.fisherdigital.org
Web Server Port Used for SSH: 22
MySQL Port in the web-server: 3306 (default mysql port)
My IP: 173.X.X.X
My machine name is: webdev02

My Code looks as follows:
                Connection conn = null;
                
                JSch jsc = new JSch();
                
                java.util.Properties config = new java.util.Properties();
                config.put("StrictHostKeyChecking", "no");
                String user = sshUserName;
                String rhost ="webdev02";
                String host = "web1.fisherdigital.org";
                
                int sshPort = 22, lport = 2122, rport = 3306;
                Session session = jsc.getSession(user, host, sshPort);
                
                session.setConfig(config); session.setHost(host);
session.setPassword(sshUserPassword);
                session.connect();
                int assigned_port = session.setPortForwardingL(lport, rhost, 
rport);
                
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                System.out.println("Attempting to connect....");
                conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:" +
assigned_port + "/schemaName", dbUser, dbUserPassword);
                System.out.println("CONNECTED!");
                conn.close();
                System.exit(1);

The issue is that whenever I use DriverManager.getConnection, it
outputs Attempting to connect.... then hangs.

Any pointers would be appreciated.
- Elm

------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to