Package org.sd_network.db

Examples of org.sd_network.db.ConnectionPool


        try {
            // setup configurations.
            Config config = Config.load(propertyFilePath);

            // setup database connection information.
            ConnectionPool pool = ConnectionPool.getInstance("vfs");
            pool.setJDBCDriver(
                    config.getProperty("org.sd_network.vfs.db.JDBCDriver"));
            pool.setDatabaseURL(
                    config.getProperty("org.sd_network.vfs.db.URL"));
            pool.setDatabaseUserName(
                    config.getProperty("org.sd_network.vfs.db.UserName"));
            pool.setDatabasePassword(
                    config.getProperty("org.sd_network.vfs.db.Password"));

            // setup database schema.
            Schema.setup();
View Full Code Here


        if (loginName == null || loginName.length() == 0)
            throw new IllegalArgumentException("loginName is empty.");
        if (password == null || password.length() == 0)
            throw new IllegalArgumentException("password is empty.");

        ConnectionPool pool = ConnectionPool.getInstance("vfs");
        Connection con = pool.engageConnection(10);
        try {
            PreparedStatement stmt = con.prepareStatement(
                    "SELECT user_id, login_name, is_admin FROM user " +
                    " WHERE login_name = ? AND password = ?");
            stmt.setString(1, loginName);
View Full Code Here

     *          Throws when each argument is specified null or empty.
     */
    public static final User create(String loginName, String password,
            boolean isAdmin)
    {
        ConnectionPool pool = ConnectionPool.getInstance("vfs");
        Connection con = pool.engageConnection(10);
        try {
            con.setAutoCommit(true);
            return create(con, loginName, password, isAdmin);
        } catch (SQLException e) {
            throw new DBException(e);
View Full Code Here

        User user = userSession.getUser();
        if (!user.isAdmin())
            throw new PermissionException(
                    "You have not permission as an Administrator.");

        ConnectionPool pool = ConnectionPool.getInstance("vfs");
        Connection con = pool.engageConnection(10);
        try {
            con.setAutoCommit(false);
            User newUser = UserDB.create(con, loginName, password, isAdmin);

            // If new user is not administrator, create HOME directory of user.
View Full Code Here

     */
    public byte[] getContent() {
        if (_content != null)
            return _content;

        ConnectionPool pool = ConnectionPool.getInstance("vfssector");
        Connection con = pool.engageConnection(10);
        PreparedStatement stmt = null;
        try {
            stmt = con.prepareStatement(
                    "SELECT content FROM sector WHERE sector_id=?");
            stmt.setString(1, _sectorID);
View Full Code Here

        if (_initialized)
            return;

        // setup database connection informations.
        try {
            ConnectionPool pool = ConnectionPool.getInstance("vfssector");
        } catch (ConnectionPoolException e) {
            throw new SectorException(e.getMessage());
        }

        try {
View Full Code Here

            throw new IllegalArgumentException("content was empty.");
        if (content.length < size || size <= 0)
            throw new IllegalArgumentException("invalid size.");

        String sectorID = UUID.randomUUID().toString();
        ConnectionPool pool = ConnectionPool.getInstance("vfssector");
        Connection con = pool.engageConnection(10);
        PreparedStatement stmt = null;
        try {
            stmt = con.prepareStatement(
                    "INSERT INTO sector " +
                    " (sector_id, file_id, seq_num, size, content) " +
View Full Code Here

     */
    public static final byte[] getContent(String sectorID) {
        if (sectorID == null)
            throw new NullPointerException("sectorID");

        ConnectionPool pool = ConnectionPool.getInstance("vfssector");
        Connection con = pool.engageConnection(10);
        PreparedStatement stmt = null;
        try {
            stmt = con.prepareStatement(
                    "SELECT content FROM sector WHERE sector_id=?");
            stmt.setString(1, sectorID);
View Full Code Here

        if (content.length == 0)
            throw new IllegalArgumentException("content was empty.");
        if (content.length < size || size <= 0)
            throw new IllegalArgumentException("invalid size.");

        ConnectionPool pool = ConnectionPool.getInstance("vfssector");
        Connection con = pool.engageConnection(10);
        PreparedStatement stmt = null;
        try {
            stmt = con.prepareStatement(
                    "UPDATE sector SET size=?, content=? " +
                    "WHERE sector_id=?");
View Full Code Here

     */
    public static final Sector getLastSector(String fileID) {
        if (fileID == null)
            throw new NullPointerException("fileID.");

        ConnectionPool pool = ConnectionPool.getInstance("vfssector");
        Connection con = pool.engageConnection(10);
        PreparedStatement stmt = null;
        try {
            stmt = con.prepareStatement(
                    "SELECT sector_id, file_id, seq_num, size " +
                    "FROM " +
View Full Code Here

TOP

Related Classes of org.sd_network.db.ConnectionPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.