P Patrick Clark Active Member Licensed User Jun 11, 2020 #1 Hi I am trying to connect to a MS SQL server. I have the B4X: #AdditionalJar: jtds-1.3.1.jar along with the jar file in Additional Libraries With SMSS I can connect with 192.168.1.145\SQLEXPRESS where I have a database called test if I try and connect with B4X: Private SQL1 As SQL 'in Class Globals or Process Globals SQL1.Initialize2("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://192.168.1.145/SQLEXPRESS/test", "user", "password") I get the following timeout error in the logs. Any ideas? java.sql.SQLException: Network error IOException: Connection timed out: connect at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:436) at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228) at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:58) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:676) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91) at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98) at anywheresoftware.b4a.BA.raiseEvent(BA.java:78) at b4j.example.main.start(main.java:38) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.net.ConnectException: Connection timed out: connect at java.base/java.net.PlainSocketImpl.connect0(Native Method) at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:101) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) at java.base/java.net.Socket.connect(Socket.java:591) at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:288) at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:251) at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:331) ... 28 more Click to expand...
Hi I am trying to connect to a MS SQL server. I have the B4X: #AdditionalJar: jtds-1.3.1.jar along with the jar file in Additional Libraries With SMSS I can connect with 192.168.1.145\SQLEXPRESS where I have a database called test if I try and connect with B4X: Private SQL1 As SQL 'in Class Globals or Process Globals SQL1.Initialize2("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://192.168.1.145/SQLEXPRESS/test", "user", "password") I get the following timeout error in the logs. Any ideas? java.sql.SQLException: Network error IOException: Connection timed out: connect at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:436) at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228) at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:58) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:676) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91) at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98) at anywheresoftware.b4a.BA.raiseEvent(BA.java:78) at b4j.example.main.start(main.java:38) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.net.ConnectException: Connection timed out: connect at java.base/java.net.PlainSocketImpl.connect0(Native Method) at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:101) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) at java.base/java.net.Socket.connect(Socket.java:591) at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:288) at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:251) at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:331) ... 28 more Click to expand...
EnriqueGonzalez Expert Licensed User Longtime User Jun 12, 2020 #2 Patrick Clark said: Any ideas? Click to expand... Best idea is to not use jtds at all. Use the official libraries. Download - JDBC Driver for SQL Server Download the Microsoft JDBC Driver for SQL Server to develop Java applications that connect to SQL Server and Azure SQL Database. docs.microsoft.com Upvote 0
Patrick Clark said: Any ideas? Click to expand... Best idea is to not use jtds at all. Use the official libraries. Download - JDBC Driver for SQL Server Download the Microsoft JDBC Driver for SQL Server to develop Java applications that connect to SQL Server and Azure SQL Database. docs.microsoft.com
EnriqueGonzalez Expert Licensed User Longtime User Jun 12, 2020 #3 After you migrate instead of using /sql express use :1433 (open tcp port in sql server configuration manager) Upvote 0
After you migrate instead of using /sql express use :1433 (open tcp port in sql server configuration manager)
P Patrick Clark Active Member Licensed User Jun 12, 2020 #4 thanks, but not quite sure what you mean, What will be my initialize statement Upvote 0
P Patrick Clark Active Member Licensed User Jun 12, 2020 #5 1433 is open in config manager and firewall Upvote 0
OliverA Expert Licensed User Longtime User Jun 12, 2020 #6 Use the MS SQL JDBC driver as suggest by @Enrique Gonzalez R . As to the JDBC driver and JDBC URL, you could try Code: SQL1.Initialize2("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://192.168.1.145;databaseName=test", "user", "password") for more information on how to construct the JDBC URL for the MS SQL JDBC driver, see: Building the connection URL with the Microsoft JDBC Driver for SQL Server - JDBC Driver for SQL Server Learn about formatting the connection string used by the Microsoft JDBC Driver for SQL Server. Samples of connection strings are included in the examples section. docs.microsoft.com If you use the default port of 1433, you usually don't have to included it in the URL. The same goes for the instance name (as per above provided link). Upvote 0
Use the MS SQL JDBC driver as suggest by @Enrique Gonzalez R . As to the JDBC driver and JDBC URL, you could try Code: SQL1.Initialize2("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://192.168.1.145;databaseName=test", "user", "password") for more information on how to construct the JDBC URL for the MS SQL JDBC driver, see: Building the connection URL with the Microsoft JDBC Driver for SQL Server - JDBC Driver for SQL Server Learn about formatting the connection string used by the Microsoft JDBC Driver for SQL Server. Samples of connection strings are included in the examples section. docs.microsoft.com If you use the default port of 1433, you usually don't have to included it in the URL. The same goes for the instance name (as per above provided link).
P Patrick Clark Active Member Licensed User Jun 12, 2020 #7 @Enrique Gonzalez R and @OliverA Thank you both. All working now Upvote 0