Solved

How do I connect to MSSQL database using RPG?

Posted on 2008-10-05
5
766 Views
Last Modified: 2011-10-19
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
0
Comment
Question by:gmollineau
  • 3
  • 2
5 Comments
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 500 total points
Comment Utility
gmollineau:

If you run this command from a command-line on your AS400:

==>  traceroute xlink_test.cansnack.com

...what is the result?

Tom
0
 

Author Comment

by:gmollineau
Comment Utility
Hi,

When I run the command I get the following:

Unknown host, XLINK_TEST.CANSNACK.COM.

0
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 500 total points
Comment Utility
gmollineau:

> When I run the command I get the following:

> Unknown host, XLINK_TEST.CANSNACK.COM.

That is probably why you're seeing the 'java.net.UnknownHostException'. You shouldn't be able to connect to a server that the system can't identify.

You'll need to configure your DNS to resolve that name or possibly add a hosts table entry, or use the IP address in place of that host name in your connection. I don't know if everything will work after that, but it should at least progress to the next error if any exist.

Tom
0
 

Author Comment

by:gmollineau
Comment Utility
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?
0
 
LVL 27

Accepted Solution

by:
tliotta earned 500 total points
Comment Utility
gmollineau:

Perhaps the best suggestion is to check:

http://www.experts-exchange.com/allTopics.jsp

Enter something like [ java jdbc ] into the search box. Review the lists of topics to see where the question might be better asked.

This isn't to push you away, but there's nothing yet that really has much to do with AS/400s as such. I mean, yes, that's where you're running the driver; but at this point in your efforts, you really ought to have some dedicated eyes looking at your java messages.

I'm guessing that the "java/JDBC" part of this is well outside of your normal efforts on your AS/400 and that that is the area you need the most help with. You had a fairly easy time of getting the 'unknown host' resolved, and that tells me you're either not entirely a novice on the AS/400 side or you have competent help locally available.

The alternative seems to be a potentially lengthy debugging series. IMO, you're better served by starting from a different position within EE.

I think if you ask an advisor here, they'll perhaps move the question to a better zone. Later questions that are more specific to AS/400s might lead back to here.

Tom
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now