This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HELP! - TOMCAT WITH DB2 NOT WORK

 
Gaston Quezada
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic