Hi Heiner!

Thank you for the advice! Shortly after e-mailing the distribution group, I
fiddled around with my hostnames.

One thing that I changed was the String rhost to be “127.0.0.1” instead
of “webdev02”. This seemed to have done the trick.

I appreciate the great and prompt response,

Hector Rios

 *From:* Heiner Westphal <westp...@verit.de>
*Sent:* ‎January‎ ‎15‎, ‎2013 ‎5‎:‎08‎ ‎PM
*To:* Hector Rios <labeledlo...@gmail.com>
*CC:* jsch-users@lists.sourceforge.net
*Subject:* Re: [JSch-users] Jsch & Databases

Hello Hector,

the long waits sounds to me like a firewall dropping the packages.
The java code looks ok, AFAICS.

There are some obstacles to circumvent in the setup outside of jsch/ssh (I
assume the webserver is running linux):
- mysqld must allow tcp connections
    check with e.g.
  sudo netstat -nlp | grep 3306
   -> should give s.t. like
        tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1234/mysqld
    or
  sudo lsof -i:3306|grep LISTEN
   -> should return something similar to
        mysqld 1234 mysql 10u IPv4 4649 0t0 TCP *:mysql (LISTEN)

- no firewall on web1.fisherdigital.org should block port 3306
    try
  sudo iptables --list
    to see the firewall rules.

On windows use
    netstat -n|find "3306"
to see if mysql listens on a tcp port (maybe mysql does it always on
windows, I'm not sure).

Best regards,

Heiner

Am 15.01.2013 23:27, schrieb Hector Rios:

> 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<http://p.sf.net/sfu/learnmore_122512>
> ______________________________**_________________
> JSch-users mailing list
> JSch-users@lists.sourceforge.**net <JSch-users@lists.sourceforge.net>
> https://lists.sourceforge.net/**lists/listinfo/jsch-users<https://lists.sourceforge.net/lists/listinfo/jsch-users>
>
>

-- 
Dipl.Inform.
Heiner Westphal
Senior Software Engineer

verit Informationssysteme GmbH
Europaallee 10
67657 Kaiserslautern

E-Mail: heiner.westp...@verit.de
Telefon: +49 631 520 840 00
Telefax: +49 631 520 840 01
Web: http://www.verit.de/

Registergericht: Amtsgericht Kaiserslautern
Registernummer: HRB 3751
Geschäftsleitung: Claudia Könnecke, Torsten Stolpmann
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to