web stats
I need to connect to an AS/400 - help please! - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-08-2010, 08:12 AM
alan alan is offline
Mirth Newb
 
Join Date: Feb 2010
Location: Modena, Italy
Posts: 8
alan is on a distinguished road
Default I need to connect to an AS/400 - help please!

edit: this solution works after restarded

I need to connect to an AS/400 for a very simple query; I have copied the jt400.jar library on lib\custom folder, then added the record
<driver class="com.ibm.as400.access.AS400JDBCDriver" name="AS400 Driver"/> on the conf\custom\dbdrivers.xml file.
On the javascript writer I've tried

var as400Conn = DatabaseConnectionFactory.createDatabaseConnection ("com.ibm.as400.access.AS400JDBCDriver", "jdbc:as400://ASDP03/UGSWRK", myname, mypassword);

var query =
"SELECT P2NOM " +
"FROM P2REFER0";

var result = as400Conn.executeCachedQuery(query);
as400Conn.close();

note: if you need a specific jt400.jar library install the as400 client access and take the jar file on the folder <InstallDir>\IBM\Client Access\jt400\lib

Last edited by alan; 06-03-2010 at 12:37 AM. Reason: solution found
Reply With Quote
  #2  
Old 02-08-2010, 09:09 AM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 727
jbartels is on a distinguished road
Default

Did you restart the Mirth service (the service, not the admin console) after placing the JAR in lib/custom?
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
  #3  
Old 02-08-2010, 09:48 AM
alan alan is offline
Mirth Newb
 
Join Date: Feb 2010
Location: Modena, Italy
Posts: 8
alan is on a distinguished road
Default

thanks for the quick reply - at some point I have restarted the pc, so the service must have reboot; any other clues?

maybe I need to register the jar file somewhere?
Reply With Quote
  #4  
Old 02-08-2010, 10:26 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

Do something like:
Code:
java.lang.Class.forName("com.ibm.as400.access.AS400JDBCDriver");
var props = new java.util.Properties();
props.put("user", "myUser");
props.put("password", "myPassword");
var conn = java.sql.DriverManager.getConnection("jdbc:as400://" + url, props);
var statement = conn.createStatement();
var resultSet = statement.executeQuery(myquery);
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #5  
Old 02-08-2010, 10:56 AM
mulaa mulaa is offline
Mirth Newb
 
Join Date: Oct 2006
Posts: 8
mulaa
Default

Not sure if its a typo in your post, but my jar file is jt400.jar not at400.jar
Reply With Quote
  #6  
Old 02-08-2010, 11:44 AM
alan alan is offline
Mirth Newb
 
Join Date: Feb 2010
Location: Modena, Italy
Posts: 8
alan is on a distinguished road
Default

Quote:
Originally Posted by mulaa View Post
Not sure if its a typo in your post, but my jar file is jt400.jar not at400.jar
yes, it was a typo in my post

Quote:
Originally Posted by dans View Post
Do something like:
Code:
java.lang.Class.forName("com.ibm.as400.access.AS400JDBCDriver");
var props = new java.util.Properties();
props.put("user", "myUser");
props.put("password", "myPassword");
var conn = java.sql.DriverManager.getConnection("jdbc:as400://" + url, props);
var statement = conn.createStatement();
var resultSet = statement.executeQuery(myquery);
I'll try tomorrow, as soon as I'm going to office... hope it works, I'm a strong believer of the possibilities offered by mirth (it has solved many problems, now we're going deeper into it)
Reply With Quote
  #7  
Old 02-09-2010, 12:25 AM
alan alan is offline
Mirth Newb
 
Join Date: Feb 2010
Location: Modena, Italy
Posts: 8
alan is on a distinguished road
Default

it works correctly now, and I haven't changed anything... I though to have rebooted the machine at some point, but probably I did it only after the installation of as400 client access and BEFORE the code writing on mirth... in substance, it was totally my fault!

however, I had to thank you all for the help, the code you post here is still useful!

ps: I edited the first post as a tutorial for someone who have the same problem, hope it helps!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:04 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation