Есть БД с ssh-tunneling.
Через SQLyog и через DataTable в IdeaIJ к этой БД нормально подключаюсь. И мне нужно подключиться и выполнять запросы через java шатко-валко написала такой код:
Connection con = null;
JSch jsch = new JSch();
Session session = jsch.getSession(proxyUser, proxyHost, 22);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword(proxyPassword);
session.setConfig("PreferredAuthentications", "publickey,keyboard-interactive,password");
session.connect();
session.setPortForwardingL(localPort, url, 3306);
Properties properties = new Properties();
properties.setProperty("user", user);
properties.setProperty("password", password);
properties.setProperty("useUnicode", "true");
properties.setProperty("characterEncoding", "UTF-8");
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(
"jdbc:mysql://" + url + ":" + localPort + "/" + nameBD + "?autoReconnect=true", properties);
и вот на последней строчке ошибка:
Could not create connection to database server. Attempted reconnect 3 times. Giving up
Подскажите, пожалуйста, как такую проблему можно решить?
Полностью логи:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2253) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:718) at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:208) at ru.gamble.stepdefs.CommonStepDefs.ww(CommonStepDefs.java:968) at ru.gamble.stepdefs.CommonStepDefs.confirmEmail2(CommonStepDefs.java:929) at ✽.берем "PHONE"(C:/IdeaProject/autotests/autotests-888-m/src/test/resources/features/registration-authorization/testORTAX.feature:16) Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.(Socket.java:434) at java.net.Socket.(Socket.java:244) at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253) at com.mysql.jdbc.MysqlIO.(MysqlIO.java:280) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2177) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:718) at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:208) at ru.gamble.stepdefs.CommonStepDefs.ww(CommonStepDefs.java:968) at ru.gamble.stepdefs.CommonStepDefs.confirmEmail2(CommonStepDefs.java:929) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)
Виртуальный выделенный сервер (VDS) становится отличным выбором
Я разрабатываю приложение под android, и уже в течении долгого времени не могу решить одну проблему, а именно:
Вот если зайти на саму карту гугл и ввести в поиск магазины, то будет примерно такой результат
Как постоянно получать координаты курсора по X и Y с помощью Javascript?