Link to home
Start Free TrialLog in
Avatar of gmollineau
gmollineauFlag for Trinidad and Tobago

asked on

How do I connect to MSSQL database using RPG?

Hi,
I am trying to connect to a MS SQL (2005) database from an AS400 running V5R2. I am using type 4 JDBC for MSSQL version 1.1 and JDK 1.4 is installed on the AS400. I found some code at the following url http://systeminetwork.com/article/access-ms-sql-server-database-rpg-program and I was trying to use it but I am getting the following error and need help "com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host  has failed. java.net.UnknownHostException:". I have checked the MS SQL configuration and it has the TCP/IP active. The server with the MS SQL is running Windows 2000 Server.
I have attached a compile listing of the program I am using.

Thanks.
SQLSERVER590557.txt
SOLUTION
Avatar of Member_2_276102
Member_2_276102

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gmollineau

ASKER

Hi,

When I run the command I get the following:

Unknown host, XLINK_TEST.CANSNACK.COM.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

I added the entry to the host table on the as400 and did the traceroute xlink_test.cansnack.com the following was recieved:
                                                                             
Message ID . . . . . . :   TCP3261                                          
Date sent  . . . . . . :   10/10/08      Time sent  . . . . . . :   08:01:30
                                                                             
Message . . . . :   1 XLINK_TEST.CANSNACK.COM (192.168.1.28) 0.640 0.590 0.56
                                                                             
Cause . . . . . :   For hop 1, one or more responses were received from      
  XLINK_TEST.CANSNACK.COM (192.168.1.28). The response times in milliseconds
  are:                                                                      
  0.640 0.590 0.561                                                          
                                                                             
Notes . . . . . :                                                            
  - An asterisk (*) indicates a response packet was not received within the  
    specified time.                                                          
  - The abbreviations below are appended to a response time to highlight    
    specific ICMP response messages.                                        
    /0 Network unreachable.                                                  

When I tried to run the program again I got the following message:

com.microsoft.sqlserver.jdbc.SQLServerException: : Unrecoverable error        
 at java/lang/Throwable.<init>(Throwable.java:195)                            
 at java/lang/Exception.<init>(Exception.java:41)                              
 at java/sql/SQLException.<init>(SQLException.java:40)                        
 at com/microsoft/sqlserver/jdbc/SQLServerException.<init>(Unknown Source)    
 at com/microsoft/sqlserver/jdbc/SQLServerException.makeFromDriverError(Unknown Source)
 at com/microsoft/sqlserver/jdbc/SQLServerConnection.sendLogon(Unknown Source)
 at com/microsoft/sqlserver/jdbc/SQLServerConnection.logon(Unknown Source)    
 at com/microsoft/sqlserver/jdbc/SQLServerConnection.connectHelper(Unknown Source)
 at com/microsoft/sqlserver/jdbc/SQLServerConnection.loginWithoutFailover(Unknown Source)
 at com/microsoft/sqlserver/jdbc/SQLServerConnection.connect(Unknown Source)  
 at com/microsoft/sqlserver/jdbc/SQLServerDriver.connect(Unknown Source)      

I am running the program from a cl which looks like the following:
*************** Beginning of data ***********************************
PGM                                                                  
                                                                     
                                                                     
OVRPRTF FILE(STDOUT) TOFILE(QSYSPRT) HOLD(*YES) OVRSCOPE(*JOB)      
OVRPRTF FILE(STDERR) TOFILE(QSYSPRT) HOLD(*YES) OVRSCOPE(*JOB)      
                                                                     
/*           ADDENVVAR  ENVVAR(QIBM_RPG_JAVA_PROPERTIES) +          
                          VALUE('-Djava.version=1.4;+                
                          Djava.awt.headless=true;+                  
                          Dos400.awt.native=true;')     */          
                                                                     
             ADDENVVAR  ENVVAR(QIBM_RPG_JAVA_PROPERTIES) +          
                          VALUE('-Djava.version=1.4;')              
                                                                     
   /*        ADDENVVAR  ENVVAR(CLASSPATH) +                          
                          VALUE('/home/QIBM/UserData/Java400/ext;/hom+
                          e/QIBM/ProdData/HTTP/Public/jt400/lib/jt400+
                          .jar;/home/QIBM/ProdData/Java400/ext')   */  
                                                                       
   CALL SQLSERVER                                                      
                                                                       
ENDPGM                                                                
****************** End of data ****************************************

Any suggestions?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial