简体   繁体   English

将iSeries JDBC连接到Microsoft Azure SQL Server

[英]Connecting iSeries JDBC to Microsoft Azure SQL Server

I have used Scott Klement's example code to create a connection from our iSeries (level V5R2M0) using jtds-1.3.1.jar to our Azure SQL Server. 我使用了Scott Klement的示例代码,使用jtds-1.3.1.jar从我们的iSeries(级别V5R2M0)创建到我们的Azure SQL Server的连接。 Scott's example RPG ILE program MSSQLTEST gets as far as the connection value test which fails as it is always Null. Scott的示例RPG ILE程序MSSQLTEST获取连接值测试失败,因为它总是为空。 The Java software successfully loads and shows no errors. Java软件成功加载并显示没有错误。 The following is the code in question: 以下是有问题的代码:

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: 连接参数由Microsoft提供为:

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 have tried the following to try and make the connection work: 我尝试了以下尝试使连接工作:

Added a port forward on our router for port 1433 which points to our iSeries IP address 在我们的路由器上为端口1433添加了一个端口,指向我们的iSeries IP地址

Added our external IP address to our Azure SQL Server firewall 将我们的外部IP地址添加到Azure SQL Server防火墙

I have tested the connection parameters by creating an ODBC connection to our Azure SQL Server on a PC which works 我已经通过在PC上创建与Azure SQL Server的ODBC连接来测试连接参数

Does anyone have this working between the iSeries and Azure SQL Server? 有没有人在iSeries和Azure SQL Server之间工作?

I haven't used jTDS, but from my experience Microsoft recommends us to use SQL Server JDBC (sqljdbc.jar or sqljdbc4.jar) to connect to Azure SQL Database from Java. 我没有使用过jTDS,但根据我的经验,Microsoft建议我们使用SQL Server JDBC(sqljdbc.jar或sqljdbc4.jar)从Java连接到Azure SQL数据库。 You can refer to https://msdn.microsoft.com/library/gg715284.aspx for a sample and you may want to check out http://as400blog.blogspot.mx/2009/09/need-to-access-ms-sql-databases-from.html to see how to leverage this driver. 您可以参考https://msdn.microsoft.com/library/gg715284.aspx获取样本,您可以查看http://as400blog.blogspot.mx/2009/09/need-to-access-ms -sql-databases-from.html了解如何利用此驱动程序。

I noticed that in the connection string provided by the Azure portal, the key word for user is user , not userName . 我注意到在Azure门户提供的连接字符串中,用户的关键字是user ,而不是userName Once I set the value for user using JDBC_setprop , it worked for me. 一旦我使用JDBC_setpropuser设置了值,它对我JDBC_setprop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM