本文整理匯總了Java中com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException類的典型用法代碼示例。如果您正苦於以下問題:Java MySQLSyntaxErrorException類的具體用法?Java MySQLSyntaxErrorException怎麽用?Java MySQLSyntaxErrorException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MySQLSyntaxErrorException類屬於com.mysql.jdbc.exceptions.jdbc4包,在下文中一共展示了MySQLSyntaxErrorException類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: insert_no_permission
import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException; //導入依賴的package包/類
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);
}
}
示例2: createTable_no_permission
import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException; //導入依賴的package包/類
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);
}
}
示例3: main
import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException; //導入依賴的package包/類
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException, SQLException {
GuiNome guiNome = new GuiNome();
CreateDb createDb = new CreateDb();
boolean controllo = false;
try{
controllo = createDb.FirstAccess();
}catch(MySQLSyntaxErrorException ex){
}
if(controllo){
createDb.toJavaFromDbSale();
createDb.toJavaFromDbPortate();
createDb.toJavaFromDbNome();
createDb.toJavaFromDbPrenotazioni();
GuiPrincipale guiProva = new GuiPrincipale();
guiProva.refreshNumber();
guiProva.setLocationRelativeTo(null);
guiProva.setVisible(true);
}else
guiNome.setVisible(true);
}
示例4: isDatabaseNameTooLongException
import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException; //導入依賴的package包/類
/**
* 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;
}
示例5: isDatabaseDoesNotExistException
import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException; //導入依賴的package包/類
/**
* 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;
}