Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005

    Unanswered: CAN NOT produce preparedStatement with

    Hi everyone,

    I'm using WebSphere 5.1.2 as application developer and DB2 8.1.7 UDB as DBMS. I develop a web application in struts environment. Everything's fine when I make Statement but I have a problem preparing statements with conn.prepareStatement(strQry). I've made a long research in Internet, found some solutions like "add db2jcc.jar," to the classpath" for the same problem but I already have them in my classpath. Anyway, here's my settings and the information that I think neccessary. If you wonder any other settings in my comp. I'm ready to write them later.

    In the WebSphere console it says :

    [23.01.2005 15:06:33:438 EET] 231c4689 WebGroup E SRVE0026E: [Servlet Error]-[com/ibm/db2/jcc/SQLJPackage]: java.lang.NoClassDefFoundError: com/ibm/db2/jcc/SQLJPackage
    at t(Unknown Source)
    at org.apache.commons.dbcp.DelegatingConnection.prepa reStatement(
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuar dConnectionWrapper.prepareStatement(PoolingDataSou
    at com.yildiz.mersam.actions.DosyaAction.processUploa dedFile(
    at com.yildiz.mersam.actions.DosyaAction.execute(Dosy
    at org.apache.struts.action.RequestProcessor.processA ctionPerform(
    at org.apache.struts.action.RequestProcessor.process(
    at org.apache.struts.action.ActionServlet.process(Act
    at org.apache.struts.action.ActionServlet.doPost(Acti
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at ...

    and meanwhile on the browser it displays : Error 500: com/ibm/db2/jcc/SQLJPackage
    (Note that class is in db2jcc.jar)

    my classpath variables are :

    C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.j ar;

    and I have all the necessary jars, zips in WEB-INF/lib directory(At least I have no problems in making raw Statement queries).

    Here's my data-source settings in struts-config.xml :

    <data-source key="mersam" type="org.apache.commons.dbcp.BasicDataSource">
    <set-property property="url" value="jdbc:db2://"/>
    <set-property property="username" value="user"/>
    <set-property property="password" value="pass"/>
    <set-property property="driverClassName" value=""/>

    The actual method accessing the DB in Action class is as follows :

    private int processUploadedFile(FileItem item) {
    Connection conn = null;
    PreparedStatement prestmt = null;
    int result = -1;
    String strQry = null;
    ServletContext servletContext = servlet.getServletContext();

    // request is globally defined in Class
    DataSource dataSource = getDataSource(request, "mersam");

    String fieldName = item.getFieldName();
    String fileName = item.getName();
    String contentType = item.getContentType();

    InputStream is = item.getInputStream();


    try {

    conn = dataSource.getConnection();
    strQry = "INSERT INTO MERSAM.DOSYALAR(dosya, file_name) " +
    "VALUES(?, ?)";

    prestmt = conn.prepareStatement(strQry);
    prestmt.setBinaryStream(1, is, (int)size);
    prestmt.setString(2, fileName);
    result = prestmt.executeUpdate();

    } catch (SQLException e) {

    return result;


    In some forums, "" in is said to be unsupported driver for preparedStatements. OK, but what is the alternative ??

  2. #2
    Join Date
    Aug 2002


    We use it for prepared statements on both 7.2 and 8.2

    I believe it is also in so your classpath should be fine

  3. #3
    Join Date
    Feb 2005


    I think that the main problem is
    java.lang.NoClassDefFoundError: com/ibm/db2/jcc/SQLJPackage
    However this class is already included in db2jcc.jar !!
    Anyway, I've tried but it gives the same problem. May it be concerned with the classpath settings ??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts