use of com.mysql.cj.xdevapi.Schema in project aws-mysql-jdbc by awslabs.
the class DevApiSample method main.
public static void main(String[] args) {
Session session = new SessionFactory().getSession("mysqlx://localhost:33060/test?user=user&password=password1234");
System.err.println("Connected!");
Schema schema = session.getDefaultSchema();
System.err.println("Default schema is: " + schema);
documentWalkthrough(schema);
}
use of com.mysql.cj.xdevapi.Schema in project aws-mysql-jdbc by awslabs.
the class SchemaTest method testToString.
@Test
public void testToString() {
// this will pass as long as the test database doesn't require identifier quoting
assertEquals("Schema(" + getTestDatabase() + ")", this.schema.toString());
Schema needsQuoted = this.session.getSchema("terrible'schema`name");
assertEquals("Schema(`terrible'schema``name`)", needsQuoted.toString());
}
use of com.mysql.cj.xdevapi.Schema in project aws-mysql-jdbc by awslabs.
the class SchemaTest method testEquals.
@Test
public void testEquals() {
Schema otherDefaultSchema = this.session.getDefaultSchema();
assertFalse(otherDefaultSchema == this.schema);
assertTrue(otherDefaultSchema.equals(this.schema));
assertTrue(this.schema.equals(otherDefaultSchema));
Session otherSession = new SessionImpl(this.testHostInfo);
Schema diffSessionSchema = otherSession.getDefaultSchema();
assertEquals(this.schema.getName(), diffSessionSchema.getName());
assertFalse(this.schema.equals(diffSessionSchema));
assertFalse(diffSessionSchema.equals(this.schema));
otherSession.close();
}
use of com.mysql.cj.xdevapi.Schema in project aws-mysql-jdbc by awslabs.
the class SchemaTest method testExists.
@Test
public void testExists() {
assertEquals(DbObjectStatus.EXISTS, this.schema.existsInDatabase());
Schema nonExistingSchema = this.session.getSchema(getTestDatabase() + "_SHOULD_NOT_EXIST_0xCAFEBABE");
assertEquals(DbObjectStatus.NOT_EXISTS, nonExistingSchema.existsInDatabase());
}
use of com.mysql.cj.xdevapi.Schema in project aws-mysql-jdbc by awslabs.
the class SessionTest method createExistingSchemaError.
@Test
public void createExistingSchemaError() {
String testSchemaName = getRandomTestSchemaName();
Schema newSchema = this.session.createSchema(testSchemaName);
assertTrue(this.session.getSchemas().contains(newSchema));
try {
this.session.createSchema(testSchemaName);
fail("Attempt to create a schema with the name of an existing schema should fail");
} catch (XProtocolError err) {
assertEquals(MysqlErrorNumbers.ER_DB_CREATE_EXISTS, err.getErrorCode());
}
}
Aggregations