Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NPE - 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;
- }
- }
Add Comment
Please, Sign In to add comment