Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I connect to MSSQL database using RPG?

Posted on 2008-10-05
5
Medium Priority
?
787 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 2000 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 2000 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
Let's take a look into the basics of ransomware—how it spreads, how it can hurt us, and why a disaster recovery plan is important.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 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