Mysql-Proxy and Java Socket connection
Hi,
I am new to this mysql-proxy, and am working my way through it.
So far, I have it up and running and talking to two backend servers.
I have set up IPTABLES redirection:
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination
1 REDIRECT tcp -- 127.0.0.1 127.0.0.1 tcp dpt:3306 redir ports 4040
2 REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306 redir ports 4040
3 REDIRECT tcp -- 10.4.23.107 10.4.23.107 tcp dpt:3306 redir ports 4040
Which means I can connect from a command line "mysql" connection using port 3306, which then means other applications can connect as well. Such asa MySQL Query Browser.
The problem I have is when the Java Application fires up, it seems to be using sockets (java is not my area of expertise), and hence it cannot connect, I get pages of errors, but generally they tell me this:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:209)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:173)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:267)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2739)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
I have spent the last few hours googling this, but still cannot get it to work, I have tried including something called socat, which was recommended somewehere, but I still cannot get it to work.
So my question is guys, how can I get Java to connect, with out me having to change anything in the Java application, including DB IP's or Port Numbers.
I am using this cfg file:
[mysql-proxy]
proxy-backend-addresses = 10.150.0.39:3306
proxy-read-only-backend-addresses = 10.150.0.100:3306
proxy-address = /var/lib/mysql/mysql.sock
admin-username = root
admin-password = root
admin-lua-script = /usr/local/mysql-proxy-0.8.1-linux-rhel5-x86-32bit/lib/mysql-proxy/lua/admin.lua
proxy-lua-script = /usr/local/mysql-proxy-0.8.1-linux-rhel5-x86-32bit/scripts/kester.lua
I really hope one of you experts can help me in this. If it works, we are going to try and roll it live, so I really hope it does!
Kindest Regards,