Search in sources :

Example 21 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class IsDBAUserTaskTest method testExecuteFour.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask#execute()}
	 * .
	 * 
	 * @throws SQLException
	 */
public void testExecuteFour() {
    DbUserInfo userInfo = databaseInfo.getAuthLoginedDbUserInfo();
    String userName = userInfo.getName();
    userInfo.setName("other");
    checkTask.setErrorMsg("error");
    checkTask.execute();
    assertFalse(checkTask.isDBAUser());
    userInfo.setName(userName);
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)

Example 22 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class IsDBAUserTaskTest method testExecuteThree.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask#execute()}
	 * .
	 * 
	 * @throws SQLException
	 */
public void testExecuteThree() throws SQLException {
    Connection conn = checkTask.getConnection();
    if (conn != null) {
        conn.close();
    }
    DbUserInfo userInfo = databaseInfo.getAuthLoginedDbUserInfo();
    String userName = userInfo.getName();
    userInfo.setName("other");
    checkTask.execute();
    assertFalse(checkTask.isDBAUser());
    userInfo.setName(userName);
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) Connection(java.sql.Connection)

Example 23 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class JDBCConnectionManager method testShardBroker.

public static boolean testShardBroker(DatabaseInfo dbInfo, int shardId) {
    String dbName = dbInfo.getDbName();
    ServerInfo serverInfo = dbInfo.getServerInfo();
    String brokerIP = dbInfo.getBrokerIP();
    DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
    String url = "jdbc:cubrid:" + brokerIP + ":" + dbInfo.getBrokerPort() + ":" + dbName + ":::";
    Driver cubridDriver = CubridClassLoaderPool.getCubridDriver(serverInfo.getJdbcDriverVersion());
    if (cubridDriver == null) {
        LOGGER.error("The cubridDriver is a null.");
        return false;
    }
    Properties props = new Properties();
    props.put("user", userInfo.getName());
    props.put("password", userInfo.getNoEncryptPassword() == null ? "" : userInfo.getNoEncryptPassword());
    Connection conn = null;
    Statement stmt = null;
    try {
        conn = cubridDriver.connect(url, props);
        conn.setAutoCommit(true);
        stmt = conn.createStatement();
        stmt.executeQuery("/*+ shard_id(" + shardId + ") */ SELECT * FROM db_root");
    } catch (Exception e) {
        LOGGER.error("", e);
        return false;
    } finally {
        QueryUtil.freeQuery(conn, stmt);
    }
    return true;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Statement(java.sql.Statement) Connection(java.sql.Connection) Driver(java.sql.Driver) Properties(java.util.Properties) SQLException(java.sql.SQLException)

Example 24 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class JDBCConnectionManager method getConnection.

/**
	 * Get new JDBC connection
	 * 
	 * @param dbInfo DatabaseInfo The given info of DatabaseInfo
	 * @param autoCommit boolean Whether is autoCommit
	 * @throws SQLException A SQLException will be throws when exception occur
	 * @return Connection
	 */
public static Connection getConnection(DatabaseInfo dbInfo, boolean autoCommit) throws SQLException {
    if (dbInfo == null || dbInfo.getServerInfo() == null) {
        throw new IllegalArgumentException();
    }
    String dbName = dbInfo.getDbName();
    ServerInfo serverInfo = dbInfo.getServerInfo();
    String brokerIP = dbInfo.getBrokerIP();
    String brokerPort = dbInfo.getBrokerPort();
    DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
    String userName = userInfo.getName();
    String password = userInfo.getNoEncryptPassword();
    String charset = dbInfo.getCharSet();
    String driverVersion = serverInfo.getJdbcDriverVersion();
    // advanced jdbc settings
    String jdbcAttrs = dbInfo.getJdbcAttrs();
    boolean isShard = dbInfo.isShard();
    return getConnection(brokerIP, brokerPort, dbName, userName, password, charset, jdbcAttrs, driverVersion, autoCommit, isShard);
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 25 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class DatabaseInfo method clone.

/**
	 * Flat clone
	 */
public DatabaseInfo clone() throws CloneNotSupportedException {
    DatabaseInfo obj = (DatabaseInfo) super.clone();
    DbUserInfo userInfo = null;
    if (this.authLoginedDbUserInfo != null) {
        userInfo = authLoginedDbUserInfo.clone();
    }
    obj.setAuthLoginedDbUserInfo(userInfo);
    return obj;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)

Aggregations

DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)80 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)36 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)30 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)16 ArrayList (java.util.ArrayList)14 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)10 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 DbUserInfoList (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)8 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)7 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)6 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 IsDBAUserTask (com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask)6 CQBDbConnectionLoader (com.cubrid.cubridmanager.ui.spi.model.loader.CQBDbConnectionLoader)6 HashMap (java.util.HashMap)6 CubridNodeLoader (com.cubrid.common.ui.spi.model.CubridNodeLoader)5 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)5