Hi, does anyone here have a recommended method to using java code to open a remote ssh tunnel connection to start out a job?
To at least start somewhere I downloaded and added the latest version of jsch jsch-0.1.50.jar to my user libraries
Also found a sample script to connect here: http://mws-mdm.blogspot.ca/2013/07/jdbc … unnel.html
To get myself started I put that script verbatim into a tJava component; but it looks like the script is going to need to be Talend-ized in order to make it work. Tried it out of the box and got a number of errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: Syntax error on token "import", assert expected java.sql.Connection cannot be resolved to a variable Syntax error on token "import", assert expected java.sql.DriverManager cannot be resolved to a variable Syntax error on token "import", assert expected java.util.Properties cannot be resolved to a variable Syntax error on token "import", assert expected com.jcraft cannot be resolved to a variable Syntax error on token "import", assert expected com.jcraft cannot be resolved to a variable Syntax error on token "import", assert expected com.jcraft cannot be resolved to a variable Illegal modifier for the local class CTestDriver; only abstract or final is permitted The method doSshTunnel cannot be declared static; static methods can only be declared in a static or top level type JSchException cannot be resolved to a type JSch cannot be resolved to a type JSch cannot be resolved to a type Session cannot be resolved to a type Properties cannot be resolved to a type Properties cannot be resolved to a type The method main cannot be declared static; static methods can only be declared in a static or top level type The method doSshTunnel(String, String, String, int, String, int, int) from the type CTestDriver refers to the missing type JSchException Connection cannot be resolved to a type DriverManager cannot be resolved at natcobidw.testingssh_0_1.TestingSSH.tJava_1Process(TestingSSH.java:341) at natcobidw.testingssh_0_1.TestingSSH.runJobInTOS(TestingSSH.java:1308) at natcobidw.testingssh_0_1.TestingSSH.main(TestingSSH.java:1173)
Perhaps someone could help me tweak my method to get it working?
Or, perhaps someone has already gone down this path and could lay out some steps for me to follow?
PS - I'm attempting to connect to a remote MySQL database
Last edited by ddctf (2014-02-13 21:13:22)
Hi, I started working with this component and then hit a rather strange error that I've never seen before:
Exception in component tMysqlRow_1 com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4739923 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable. at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:605) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1078) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) [statistics] disconnected at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:221) at ourworkspace.testingssh_0_1.TestingSSH.tMysqlRow_1Process(TestingSSH.java:703) at ourworkspace.testingssh_0_1.TestingSSH.tSshTunnel_2Process(TestingSSH.java:375) at ourworkspace.testingssh_0_1.TestingSSH.runJobInTOS(TestingSSH.java:1060) at ourworkspace.testingssh_0_1.TestingSSH.main(TestingSSH.java:925)
The max_allowed_packet variable was adjusted (though it's never been a problem before); I feel like this error might be bogus and something else might be going on, but I'm not sure
Last edited by ddctf (2014-02-13 22:27:48)
Hi thanks for the suggestion
Is this the right idea for tSystem commands?
1. Connect to remote server
2. Start MySQL
3. Enter my MySQL query
Then pass the resulting data on to my next component (e.g. tMap) via Main row connector?
No I mean something like this:
tSystem (call the necessary ssh command) --(OnSubjobOK)--> tMysqlConnection --(OnSubjobOK)--> ... any mysql comps in flows.
your fiest component is System or there is a tSSH before it?
I have a problem to connect to Mysql with ssh.
There is a user component in Talend Exchange called tSshTunnel. I would try this.
How to configure tSSHTunnel or tSSH to connect MySql with SSH?
I have a problem to connect to MySql with SSH, i dont know about the command on tSSH or tSystem
Hope somebody can help me.