我正在处理一个电子邮件数据库程序,当我试图将电子邮件存储到数据库中时,我继续得到一个语法错误,我不确定为什么会发生这种情况。我以完全相同的方式存储用户对象,尽管它确实将用户对象存储到数据库中,但当我退出程序并再次测试程序时,它最终更新了数据库中的一些值,而不是插入新值。语法错误是否来自于我的一些列存储BLOB的事实?
'CREATE TABLE `item` (\n `Id` int(10) unsigned NOT NULL DEFAULT \'0\',\n `To` varchar(300) NOT NULL COMMENT \'To\',\n `From` varchar(300) NOT NULL,\n `Subject` varchar(45) NOT NULL COMMENT \'subject\',\n `topic` varchar(45) NOT NULL COMMENT \'category\',\n `Email_Content` blob NOT NULL COMMENT \'Email Content may change\',\n `Comments` blob,\n `Attachments` blob,\n PRIMARY KEY (`Id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8'
public void storeItem() throws SQLException{
String checkSql = "select count(*) as count from item where Id=?";
PreparedStatement checkStatement = con.prepareStatement(checkSql);
String storeSql = "insert into item(Id, To, From, Subject, topic, Email_Content, Comments, Attachments) values(?,?,?,?,?,?,?,?)";
PreparedStatement insertStatement = con.prepareStatement(storeSql);
String updateSql = "insert into set To=? From=?, Subject=?, topic=?, Email_Address=?, Comments=?, Attachments=? where Id=?";
PreparedStatement updateStatement = con.prepareStatement(updateSql);
for(Item items: Items){
int ItemId = items.getId();
String To = items.getTo();
String From = items.getFrom();
String Subject = items.getSubject();
String Topic = items.getTopic();
String Email = items.getMessageContent();
String Comments = items.getComments();
String attachments = items.getAttachments();
checkStatement.setInt(1, ItemId);
ResultSet checkResult = checkStatement.executeQuery();
checkResult.next();
int count = checkResult.getInt(1);
if (count == 0) {
System.out.println("Inserting person with ID " + ItemId);
int col = 1;
insertStatement.setInt(col++, ItemId);
insertStatement.setString(col++, To);
insertStatement.setString(col++, From);
insertStatement.setString(col++, Subject);
insertStatement.setString(col++, Topic);
insertStatement.setString(col++, Email);
insertStatement.setString(col++, Comments);
insertStatement.setString(col++, attachments);
insertStatement.executeUpdate();
} else {
System.out.println("Updating person with ID " + ItemId);
int col = 1;
updateStatement.setString(col++, To);
updateStatement.setString(col++, From);
updateStatement.setString(col++, Subject);
updateStatement.setString(col++, Topic);
updateStatement.setString(col++, Email);
updateStatement.setString(col++, Comments);
updateStatement.setString(col++, attachments);
updateStatement.setInt(col++, ItemId);
updateStatement.executeUpdate();
}
System.out.println("Count for person with ID " + ItemId + " is " + count);
}
updateStatement.close();
insertStatement.close();
checkStatement.close();
}
public void storeItem() throws SQLException{
dc.storeItem();
}
大型机类
public void completeEventOccurred() {
if (LoadEmailPanel.getComplete() == true) {
String To = LoadEmailPanel.getText(1);
String From = LoadEmailPanel.getText(2);
String Subject = LoadEmailPanel.getText(3);
String Topic = LoadEmailPanel.getText(4);
String Email = LoadEmailPanel.getText(5);
String Notes = LoadEmailPanel.getText(6);
String Attach = LoadEmailPanel.getText(7);
EmailEvent ev = new EmailEvent(this, To, From, Subject,
Topic, Email, Notes, Attach);
controller.addEmail(ev);
connect();
try {
controller.storeItem();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cards.show(MainFrame.this.getContentPane(), "Home");
}
}
});
JOptionPane.showMessageDialog(null,query);
这将帮助您发现查询中的语法错误,在查询中使用单引号和双引号的组合
insertQuery=“插入TableName(名称,注册号,国家)值('+'''+MACK''、'+12103596'、'+India+'')”;
问题是—https://codeforces.com/problemset/problem/231/A我很确定我在Java中找到了正确的解决方案,并且在我尝试它时它工作正常,但当我提交它时,它说测试1中有错误。如果有人能指出错误,那将是一个很大的帮助。我的代码如下: 注意:请不要要求更改语言,我是编程新手,我只懂一些C和Java。
我想在三月计划一个月时间表,而不是使用静态成员。你不需要解释那些评论。“日”和“月时间表”都是类。 在我执行这段代码之前,它有两个错误。一个是“三月[]日”这句话这是一个错误。另一个是'for(int i=0;i 我不明白这些句子错在哪里。语法错误是什么?
下面是我遇到错误的程序: //导入扫描程序类导入java。util。扫描仪; 这些是我得到的错误:
错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以了解在第8行MySQL中使用“NOT NULL,date\u cree timestamp,PRIMARY KEY(id)NOT NULL,)ENGINE=InnoDB”附近的正确语法
//div class=“vp-btnc-text”xpath=“1”>cs-核心容量规划 Chropath提供的相对路径://div[contains(text(),'CS-Core Capacity Planning')] 我正在尝试的代码行是:driver.find_element_by_xpath('//div[contains(),'CS-Core Capacity Planning')
我试图使java编译类文件,但它抛出了一个错误,如何修复它。