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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations