aspose file tools*
The moose likes Tomcat and the fly likes HELP! - TOMCAT WITH DB2 NOT WORK Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "HELP! - TOMCAT WITH DB2 NOT WORK" Watch "HELP! - TOMCAT WITH DB2 NOT WORK" New topic
Author

HELP! - TOMCAT WITH DB2 NOT WORK

Gaston Quezada
Greenhorn

Joined: Apr 02, 2008
Posts: 2
I have installed in $CATALINA_HOME/lib/

db2jcc.jar
db2jcc_javax.jar
db2jcc_license_cu.jar

I have follow configuration /META-INF/context.xml in my project

<Resource name="jdbc/DB2"
factory="com.ibm.db2.jcc.DB2DataSourceFactory"
auth="Container"
type="com.ibm.db2.jcc.DB2DataSource"
driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://200.1.9.67:50000/novioslp"
username="novioslp"
password="novioslp"
maxActive="10"
maxIdle="10"
maxWait="60000"/>

------------------------------------------------------------------------
in my java code call the DataSource with follow method:

public void sqlInstaceFromContext() throws DB2Exception{
try {

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
(java:comp/env)");
com.ibm.db2.jcc.DB2DataSource ds = (com.ibm.db2.jcc.DB2DataSource)envCtx.lookup("jdbc/DB2");

this.connection = ds.getConnection();
this.statement = this.connection.createStatement();
}
catch (NamingException e) {throw new DB2Exception(e.getMessage());}
catch (SQLException e) {throw new DB2Exception(e.getMessage());}
catch (Exception e) {throw new DB2Exception(e.getMessage());}
}


But, when execute ds.getConnection() catch e Exception.

[2008-04-02 12:50:27] [_db2][ERROR][java.lang.Exception]

Has anyone else because they do not get the connection from the DataSource?
 
wood burning stoves
 
subject: HELP! - TOMCAT WITH DB2 NOT WORK