Android Question error while trying to test jtds-1.3.1

Makumbi

Well-Known Member
Licensed User
iam trying to test whether the server for jdbc2 sqlserver is ok but iam getting this error

please help i have seen erel's example but it talks about mysql please is there a step by step configuration from iis so that i can make my project run thanks
 

Attachments

  • errorasp.png
    32.9 KB · Views: 178

Makumbi

Well-Known Member
Licensed User
Hi @Makumbi

The following link shows the steps to connect to SQL Server using jRDC2.

Link: https://www.b4x.com/android/forum/t...-android-to-ms-sql-server-using-jrdc2.114856/
iam currently getting this error
B4X:
Waiting for debugger to connect...
Program started.
2020-05-10 15:01:00.596:INFO::main: Logging initialized @4641ms to org.eclipse.jetty.util.log.StdErrLog
May 10, 2020 3:01:01 PM com.mchange.v2.log.MLog
INFO: MLog clients using java 1.4+ standard logging.
May 10, 2020 3:01:02 PM com.mchange.v2.c3p0.C3P0Registry
INFO: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2020-05-10 15:01:02.970:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_211-b12
2020-05-10 15:01:03.497:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2020-05-10 15:01:03.498:INFO:oejs.session:main: No SessionScavenger set, using defaults
2020-05-10 15:01:03.508:INFO:oejs.session:main: node0 Scavenging every 660000ms
2020-05-10 15:01:03.565:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@80503{/,file:///D:/jbcdsql/jRDC%20SQL%20Server(1)/jRDC/Objects/www,AVAILABLE}
2020-05-10 15:01:03.594:INFO:oejs.AbstractNCSARequestLog:main: Opened D:\jbcdsql\jRDC SQL Server(1)\jRDC\Objects\logs\b4j-2020_05_10.request.log
2020-05-10 15:01:03.711:INFO:oejs.AbstractConnector:main: Started ServerConnector@1134983{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2020-05-10 15:01:03.713:INFO:oejs.Server:main: Started @7801ms
Emulated network latency: 100ms
jRDC is running (version = 2.22)
May 10, 2020 3:01:18 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1hge9jra91ylq9aogwyyvj|1f2a7d5, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> net.sourceforge.jtds.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1hge9jra91ylq9aogwyyvj|1f2a7d5, idleConnectionTestPeriod -> 600, initialPoolSize -> 3, jdbcUrl -> jdbc:jtds:sqlserver://192.168.43.215/TestSQLServer, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, max...
May 10, 2020 3:02:19 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@12e4917 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: Network error IOException: Connection refused: connect
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:436)
    at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)

i have used this in my connection
B4X:
#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.

#DATABASE CONFIGURATION
DriverClass=net.sourceforge.jtds.jdbc.Driver
JdbcUrl=jdbc:jtds:sqlserver://192.168.43.215/TestSQLServer
User=sa
Password=123
#Java server port
ServerPort=17178

#SQL COMMANDS
sql.select_employees=SELECT id,name,salary FROM Employees WHERE id >= ?;
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
The jTDS is an old, not really up to date way of accessing DB’s such as MSSQL. It’s primarily used on Android due to Android’s inability to work with the newer MS developed JDBC drivers. It is those newer drivers that you should be using, especially when connections to anything past 2012 SQL server. Right now the message says that the connection string you are using is not correct. Be it incorrect DB name, user name, password, maybe no SSL connection, etc. Instead of working on a solution for this driver, I would first Seith to the latest driver from MS
 
Upvote 0

Albert Kallal

Active Member
Licensed User

A few things:
These days with "requiring" the sql server browser service to be running? Well, then on the computer where sql server is running, then each instance of SQL server running gets a automatic port assigned. The browser service THEN translates that to the standard port number (1433).

Also, in the connection string? You do not include the sql instance as part of the server:
eg: NOT
dbc:jtds:sqlserver://192.168.0.120/SQLEXPRESS;DatabaseName=CUSTOMERS (wrong!!!!)

You use:
B4X:
jdbc:jtds:sqlserver://192.168.0.120;Instance=SQLEXPRESS;DatabaseName=CUSTOMERS

Note how the "instance" is to be specified separate from the server name.

I have a working sample in this thread here:


In above, I have a connection builder where you enter server, database, instance, User and pass.

So, it has this setup screen:


If above don't work, then your code will not work either. My sample (unfortunately) does not include/have port number option.
(maybe I'll add that).

so, make sure SQL browser service is running (that what translates the IP address to the actual IP address and port number that sql server now uses for the instance).

And I wish the suggestions here to try/use the Microsoft drivers would work? But I not been able to use them, but the JTS driver works fine.

This can be confusing, since the Microsoft driver DOES use the sql "instance" in the server name (or IP) part, but the JTS does not!!
(you specify the instance separate from the server name (IP) address.

Regards,
Albert D. Kallal
Edmonton, Alberta Canada
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
And I wish the suggestions here to try/use the Microsoft drivers would work? But I not been able to use them, but the JTS driver works fine.
As I stated before, Microsoft Drivers will not work on Android. This is mostly due to the fact that these drivers are targeted towards modern JDK8 and upwards. Since the original poster is using B4J, they should really be using the appropriate driver (targeting the appropriate JDK and the appropriate 32/64 bit platform)
 
Upvote 0

Albert Kallal

Active Member
Licensed User

Yes makes sense.

I did play for (chew up) a few hours trying to get the Microsoft drivers to work. Some googling resulted in some posts + discussions. It seems to fail due to the first "whack" at the server and attempts to use SSL connection. And there are options in the connection string to disable SSL, but they don't seem to work. So, it centers around the "original" handshake kind of issue. So, it starts to connect, but chokes on connecting. There are some discussions around TLS or some such - apparently some have managed to make them work.

I think MS drivers would be better, but I could not get around the SSL handshake issue - that's where the "issue" was. I suspect also that the driver was never intended for Android also crops up. I'll re-visit this issue some day, but the JTS driver been working for me rather well anyway.

R
Albert
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
I'll re-visit this issue some day
Unless something changes in the underlying Java implementation in Android, this will be a futile endeavor (wasted some time on this too).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…