⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usersprofilemanagerbean.java

📁 THIS IS A FINANCIAL BANK APPLICATION
💻 JAVA
字号:
package Pcrd.Subscription.Beans;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;

import Pcrd.Subscription.Entities.UsersProfile;
import Pcrd.Subscription.Sessions.UsersProfileManager;

@Stateless
public class UsersProfileManagerBean implements UsersProfileManager {
	@PersistenceContext
	EntityManager em;
	EntityManagerFactory emf;

	public UsersProfile connection(String login, String password) {

		Connection connect = null;

		int connection = 0;

		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			connect = (Connection) DriverManager.getConnection(
					"jdbc:oracle:thin:@192.42.172.3:1523:pcardg", login,
					password);
			connection = 0;
		}

		catch (ClassNotFoundException ex) {
			System.out.print("Classe Introuvable " + ex.getMessage());
			connection = -1;
		} catch (SQLException e) {
			System.out.print("Connection Impossible :" + e.getMessage());
			connection = -1;
			// e.printStackTrace();
		} finally {
			try {
				if (connect != null) {
					connect.close();
				}
			}

			catch (SQLException ex) {
				System.out.print("CLoture Connexion Impossible :" + ex.getMessage());
				connection = -1;
			}
		}

		if (connection == 0) {
			return (UsersProfile) em.createQuery(
					"SELECT up FROM UsersProfile up WHERE up.userCode='"
							+ login + "'").getSingleResult();
		} else {
			return null;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -