Examples of ConnectionPool


Examples of org.postgresql.jdbc2.optional.ConnectionPool

        }
    }

    public void testSerializable() throws IOException, ClassNotFoundException
    {
        ConnectionPool pool = new ConnectionPool();
        pool.setDefaultAutoCommit(false);
        pool.setServerName("db.myhost.com");
        pool.setDatabaseName("mydb");
        pool.setUser("user");
        pool.setPassword("pass");
        pool.setPortNumber(1111);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(pool);

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bais);
        ConnectionPool pool2 = (ConnectionPool)ois.readObject();

        assertEquals(pool.isDefaultAutoCommit(), pool2.isDefaultAutoCommit());
        assertEquals(pool.getServerName(), pool2.getServerName());
        assertEquals(pool.getDatabaseName(), pool2.getDatabaseName());
        assertEquals(pool.getUser(), pool2.getUser());
        assertEquals(pool.getPassword(), pool2.getPassword());
        assertEquals(pool.getPortNumber(), pool2.getPortNumber());
    }
View Full Code Here

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

Examples of org.sd_network.db.ConnectionPool

        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

Examples of org.sd_network.db.ConnectionPool

     *          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

Examples of org.sd_network.db.ConnectionPool

        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

Examples of org.sd_network.db.ConnectionPool

     */
    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

Examples of org.sd_network.db.ConnectionPool

        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

Examples of org.sd_network.db.ConnectionPool

            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

Examples of org.sd_network.db.ConnectionPool

     */
    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

Examples of org.sd_network.db.ConnectionPool

        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
TOP
Copyright © 2018 www.massapi.com. 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.