Solved

How do I connect to MSSQL database using RPG?

Posted on 2008-10-05
5
779 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 500 total points
ID: 22664447
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
ID: 22674404
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
ID: 22674441
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
ID: 22686053
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
ID: 22691690
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Check out this step-by-step guide for asking an anonymous question on Experts Exchange.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 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