/******************************************************************************* * Copyright (c) 2013 * * This File is part of NGECore2. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ package services; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; import java.sql.PreparedStatement; import main.NGECore; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; public class AdminService implements INetworkDispatch { private NGECore core; public AdminService(NGECore core) { this.core = core; } public String getAccessLevelFromDB(long id) { String accessLevel = null; PreparedStatement preparedStatement; try { preparedStatement = core.getDatabase1().preparedStatement("SELECT \"accessLevel\" FROM accounts WHERE id=" + id); ResultSet resultSet = preparedStatement.executeQuery(); if(resultSet.next()) accessLevel = resultSet.getString("accessLevel"); } catch (SQLException e) { e.printStackTrace(); } return accessLevel; } public String getAccountNameFromDB(long id) { String accountName = null; PreparedStatement preparedStatement; try { preparedStatement = core.getDatabase1().preparedStatement("SELECT user FROM accounts WHERE id=" + id); ResultSet resultSet = preparedStatement.executeQuery(); if(resultSet.next()) accountName = resultSet.getString("user"); } catch (SQLException e) { e.printStackTrace(); } return accountName; } @Override public void insertOpcodes(Map arg0, Map arg1) { } @Override public void shutdown() { } }