Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.Serializable;
- import javax.enterprise.context.SessionScoped;
- // or import javax.faces.bean.SessionScoped;
- import javax.inject.Named;
- /* include package for SHA-256 encryption */
- import java.security.NoSuchAlgorithmException;
- /* include SQL Packages */
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import javax.sql.DataSource;
- import javax.annotation.Resource;
- import javax.faces.context.FacesContext;
- import javax.inject.Inject;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpSession;
- // or import javax.faces.bean.ManagedBean;
- import org.glassfish.osgicdi.OSGiService;
- @Named("DashboardController")
- @SessionScoped
- public class Dashboard implements Serializable {
- private String storedPassword = null;
- private String stringzoro = null;
- private String stringone = null;
- private String stringtwo = null;
- private String SQL_Statement = null;
- public Dashboard() throws SQLException{
- GetVariablesDB();
- }
- /* Call the Oracle JDBC Connection driver */
- @Resource(name="jdbc/Oracle")
- private DataSource ds;
- public String getUser(){
- return stringzoro;
- }
- public String getPassword(){
- return stringone;
- }
- private void GetVariablesDB() throws SQLException {
- if (ds == null) throw new SQLException();
- Connection conn = ds.getConnection();
- if (conn == null) throw new SQLException();
- try {
- conn.setAutoCommit(false);
- boolean committed = false;
- try {
- SQL_Statement = "SELECT * from GLOBALSETTINGS";
- PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
- ResultSet result = passwordQuery.executeQuery();
- if(result.next()){
- stringzoro= result.getString("SessionTTL");
- stringone = result.getString("MAXACTIVEUSERS");
- stringtwo = result.getString("ACTIVEUSERS");
- }
- conn.commit();
- committed = true;
- } finally {
- if (!committed) conn.rollback();
- }
- }
- finally {
- conn.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement