Java Code Examples for com.mysql.cj.exceptions.MysqlErrorNumbers#ER_TABLE_EXISTS_ERROR

The following examples show how to use com.mysql.cj.exceptions.MysqlErrorNumbers#ER_TABLE_EXISTS_ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XProtocolTest.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test the create/drop collection admin commands.
 */
@Test
public void testCreateAndDropCollection() {
    if (!this.isSetForXTests) {
        return;
    }
    try {
        this.protocol.send(this.messageBuilder.buildCreateCollection(getTestDatabase(), "testCreateAndDropCollection"), 0);
        this.protocol.readQueryResult();
    } catch (XProtocolError err) {
        // leftovers, clean them up now
        if (err.getErrorCode() == MysqlErrorNumbers.ER_TABLE_EXISTS_ERROR) {
            this.protocol.send(this.messageBuilder.buildDropCollection(getTestDatabase(), "testCreateAndDropCollection"), 0);
            this.protocol.readQueryResult();
            // try again
            this.protocol.send(this.messageBuilder.buildCreateCollection(getTestDatabase(), "testCreateAndDropCollection"), 0);
            this.protocol.readQueryResult();
        } else {
            throw err;
        }
    }
    // we don't verify the existence. That's the job of the server/xplugin
    this.protocol.send(this.messageBuilder.buildDropCollection(getTestDatabase(), "testCreateAndDropCollection"), 0);
    this.protocol.readQueryResult();
}
 
Example 2
Source File: SchemaImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public Collection createCollection(String collectionName, boolean reuseExistingObject) {
    try {
        return createCollection(collectionName);
    } catch (XProtocolError ex) {
        if (ex.getErrorCode() == MysqlErrorNumbers.ER_TABLE_EXISTS_ERROR) {
            return getCollection(collectionName);
        }
        throw ex;
    }
}
 
Example 3
Source File: SchemaImpl.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
public Collection createCollection(String collectionName, boolean reuseExistingObject) {
    try {
        return createCollection(collectionName);
    } catch (XProtocolError ex) {
        if (reuseExistingObject && ex.getErrorCode() == MysqlErrorNumbers.ER_TABLE_EXISTS_ERROR) {
            return getCollection(collectionName);
        }
        throw ex;
    }
}