Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.DX_57.osgi.SH_27.impl;
- import java.sql.Connection;
- import javax.sql.DataSource;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import javax.annotation.Resource;
- import org.DX_57.osgi.SH_27.api.SessionHandle;
- public class SessionHandleImpl implements SessionHandle {
- @Resource(name="jdbc/Oracle")
- DataSource ds;
- public String CheckUserDB(String userToCheck) throws SQLException {
- String storedPassword = null;
- String error_Message = null;
- String SQL_Statement = null;
- String error_Database = null;
- if (ds == null) throw new SQLException( error_Database = "No data source");
- Connection conn = ds.getConnection();
- if (conn == null) throw new SQLException( error_Database = "No connection");
- 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();
- }
- return storedPassword;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement