NPE - java.lang.reflect.UndeclaredThrowableException

时间:2012-02-01 12:37:09

标签: java sql

我正在使用OSGI开发web java应用程序。我尝试打开JSF页面时收到此错误:java.lang.reflect.UndeclaredThrowableException

这是我正在处理的源代码:

package org.DX_57.osgi.SH_27.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.DX_57.osgi.SH_27.api.SessionHandle;

public class SessionHandleImpl implements SessionHandle {

        @Resource(name="jdbc/Oracle")
        public DataSource ds;

    public String sayHello(String name) {
        return "Howdy " + name;
    }

       public String CheckUserDB(String userToCheck){
            String storedPassword = null;
            String error_Message = null;
            String SQL_Statement = null;
            String error_Database;

       Connection conn;
        try {
            conn = ds.getConnection();



       try {
            conn.setAutoCommit(false);
            boolean committed = false;
                try {
                       SQL_Statement = "SELECT Passwd from USERS WHERE Username = ?";

                       PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
                       passwordQuery.setString(1, userToCheck);

                       ResultSet result = passwordQuery.executeQuery();

                       if(result.next()){
                            storedPassword = result.getString("Passwd");
                       }

                       conn.commit();
                       committed = true;
                 } finally {
                       if (!committed) conn.rollback();
                       }
            }
                finally {               
                conn.close();

            }  
        } catch (SQLException ex) {
            ex.printStackTrace();
        }       

       return storedPassword;       
       }              


}

这是Glassfish服务器的错误堆栈:http://pastebin.com/tvHmspjh

我可以成功编译代码但是当我尝试打开JSF页面时,我收到错误。也许我误认为try-catch语句。

祝福

0 个答案:

没有答案