com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException Java Examples
The following examples show how to use
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException.
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: JDBCTest.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void insert_no_permission() throws Exception { tearDown(); connnect(USER_NAME, USER_PASS); try { String sql = " INSERT INTO db1.mytable1 (id,title,tags,author) VALUES \n" + "(1,'baidu',['aaa','bbb'],{name='gaopan',age=26})"; int affectRows = stmt.executeUpdate(sql); } catch (Exception e) { assertTrue(e instanceof MySQLSyntaxErrorException); } }
Example #2
Source File: JDBCTest.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void createTable_no_permission() throws Exception { tearDown(); connnect(USER_NAME, USER_PASS); try { String sql = " create table db1.mytable2(id integer primary key)"; int affectRows = stmt.executeUpdate(sql); } catch (Exception e) { assertTrue(e instanceof MySQLSyntaxErrorException); } }
Example #3
Source File: ExperimentRunnerTester.java From AILibs with GNU Affero General Public License v3.0 | 5 votes |
@Test public void test4Deletion() throws ExperimentDBInteractionFailedException, ExperimentAlreadyExistsInDatabaseException { this.handle.setup(this.config); this.handle.deleteDatabase(); boolean correctExceptionObserved = false; try { this.handle.createAndGetExperiment(new Experiment(0, 0, new HashMap<>())); fail("The create statement should throw an exception."); } catch (ExperimentDBInteractionFailedException e) { correctExceptionObserved = (e.getCause() instanceof MySQLSyntaxErrorException) && ((MySQLSyntaxErrorException)e.getCause()).getMessage().equals("Table '" + this.conf.getDBDatabaseName() + "." + this.conf.getDBTableName() + "' doesn't exist"); } assertTrue(correctExceptionObserved); }
Example #4
Source File: MySQLBackendUtils.java From pinlater with Apache License 2.0 | 2 votes |
/** * Indicates whether an exception is a result of a particular database * identifier being too long . Error codes for MySQL can be found here: * http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html */ public static boolean isDatabaseNameTooLongException(Exception e) { return e instanceof MySQLSyntaxErrorException && ((MySQLSyntaxErrorException) e).getErrorCode() == MYSQL_DB_NAME_TOO_LONG_ERROR_CODE; }
Example #5
Source File: MySQLBackendUtils.java From pinlater with Apache License 2.0 | 2 votes |
/** * Indicates whether an exception is a result of a particular database or table not * existing in the MySQL instance. Error codes for MySQL can be found here: * http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html */ public static boolean isDatabaseDoesNotExistException(Exception e) { return e instanceof MySQLSyntaxErrorException && ((MySQLSyntaxErrorException) e).getErrorCode() == MYSQL_DB_DOESNT_EXIST_ERROR_CODE; }