ISeries JDBC connection to Microsoft Azure SQL Server
I used Scott Clement's sample code to create a connection to our iSeries (level V5R2M0) using jtds-1.3.1.jar on our Azure SQL Server. Scott's Example RPG ILE MSSQLTEST makes a connection test value that does not work because it is always Null. Java software loads successfully and shows no errors. Below is the code:
prop = JDBC_Properties();
JDBC_setProp(prop: 'userName' : 'dbadmin@mssqlserver');
JDBC_setProp(prop: 'password' : 'password');
JDBC_setProp(prop: 'databaseName' : 'SQLDatabase');
JDBC_setProp(prop: 'encrypt' : 'true');
JDBC_setProp(prop: 'hostNameInCertificate' : '*.database.windows.net');
JDBC_setProp(prop: 'loginTimeout' : '30');
conn = JDBC_ConnProp('net.sourceforge.jtds.jdbc.Driver'
:'jdbc:jtds:sqlserver://mssqlserver.database.windows.net:1433'
: prop );
JDBC_freeProp(prop);
if (conn = *NULL);
return;
endif;
The connection parameters were provided by Microsoft as:
jdbc:sqlserver://mssqlserver.database.windows.net:1433;database=Database;user=dbadmin@mssqlserver;password={your_password_here};encrypt=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
I tried the following to try and establish a connection:
Added a port on our router for port 1433, which points to our iSeries IP address
Added external IP address of our Azure SQL Server firewall
I tested the connection parameters by creating an ODBC connection to our Azure SQL Server on a PC that is running
Anyone working with iSeries and Azure SQL Server?
source to share
I haven't used jTDS, but in my experience Microsoft recommends that we use SQL Server JDBC (sqljdbc.jar or sqljdbc4.jar) to connect to Azure SQL Database from Java. You can refer to https://msdn.microsoft.com/library/gg715284.aspx for a sample and you can check http://as400blog.blogspot.mx/2009/09/need-to-access-ms-sql- databases-from.html for how to use this driver.
source to share