|
Chris, I sent this earlier but never saw it come through. Here is part of server.xml that you need: <Context path="/yourcontext" docBase="/yourcontextdir" debug="0"> <Resource name="jdbc/as400" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/as400"> <parameter> <name>user</name> <value>basicprofile</value> </parameter> <parameter> <name>password</name> <value>associatedpassword</value> </parameter> <parameter> <name>driverClassName</name> <value>com.ibm.as400.access.AS400JDBCDriver</value> </parameter> <parameter> <name>driverName</name> <value>jdbc:as400://host.yourdomain.com</value> </parameter> </ResourceParams> </Context> package com.yourdomain.pkg; import javax.naming.Context; import javax.naming.NamingException; import javax.naming.InitialContext; import javax.sql.DataSource; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Driver; import java.sql.SQLException; public class DBConn { public DBUtil() { registerDriver(); } public static void registerDriver(){ //com.ibm.as400.access.AS400JDBCDriver drv; try{ DriverManager.registerDriver((Driver)new com.ibm.as400.access.AS400JDBCDriver()); }catch(SQLException se){ se.printStackTrace(System.err); throw new RuntimeException(se.getMessage()); } } public static Connection getConnection(){ registerDriver(); Connection retVal = null; /* try{ retVal = DriverManager.getConnection(connString, user, password); }catch(SQLException se){ se.printStackTrace(System.err); throw new RuntimeException(se.getMessage()); } return retVal; */ try{ Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); //DataSource ds = (DataSource)envCtx.lookup("jdbc/as400"); retVal = ((DataSource)envCtx.lookup("jdbc/as400")).getConnection(); }catch(NamingException ne){ ne.printStackTrace(System.err); throw new RuntimeException(ne.getMessage()); }catch(SQLException se){ se.printStackTrace(System.err); throw new RuntimeException(se.getMessage()); } return retVal; } } This does not do proper error checking or logging. I use logkit on my system. Also, you may want to set up a native (db2) driver data source. David Morris >>> chris_price@nsb.co.uk 04/23/02 07:37 AM >>> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. -- [ Picked text/plain from multipart/alternative ] All, When deploying a WebApp in WAS, I can just configure a DataSource on the Admin console, point it at my iSeries using the native or toolbox driver, and away I go. How would I do the same thing in Tomcat? Has anyone got any samples of the .xml & .java that is required? Chris.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.