Guest User

Untitled

a guest
Aug 4th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. NPE - java.lang.reflect.UndeclaredThrowableException
  2. package org.DX_57.osgi.SH_27.impl;
  3.  
  4. import java.sql.Connection;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import javax.annotation.Resource;
  9. import javax.sql.DataSource;
  10. import org.DX_57.osgi.SH_27.api.SessionHandle;
  11.  
  12. public class SessionHandleImpl implements SessionHandle {
  13.  
  14. @Resource(name="jdbc/Oracle")
  15. public DataSource ds;
  16.  
  17. public String sayHello(String name) {
  18. return "Howdy " + name;
  19. }
  20.  
  21. public String CheckUserDB(String userToCheck){
  22. String storedPassword = null;
  23. String error_Message = null;
  24. String SQL_Statement = null;
  25. String error_Database;
  26.  
  27. Connection conn;
  28. try {
  29. conn = ds.getConnection();
  30.  
  31.  
  32.  
  33. try {
  34. conn.setAutoCommit(false);
  35. boolean committed = false;
  36. try {
  37. SQL_Statement = "SELECT Passwd from USERS WHERE Username = ?";
  38.  
  39. PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
  40. passwordQuery.setString(1, userToCheck);
  41.  
  42. ResultSet result = passwordQuery.executeQuery();
  43.  
  44. if(result.next()){
  45. storedPassword = result.getString("Passwd");
  46. }
  47.  
  48. conn.commit();
  49. committed = true;
  50. } finally {
  51. if (!committed) conn.rollback();
  52. }
  53. }
  54. finally {
  55. conn.close();
  56.  
  57. }
  58. } catch (SQLException ex) {
  59. ex.printStackTrace();
  60. }
  61.  
  62. return storedPassword;
  63. }
  64.  
  65.  
  66. }
Add Comment
Please, Sign In to add comment