【问题标题】:java.sql.SQLException: Error reading from InputStream com.sun.mail.util.DecodingExceptionjava.sql.SQLException:从 InputStream com.sun.mail.util.DecodingException 读取时出错
【发布时间】:2014-06-08 04:56:11
【问题描述】:

我正在使用 JavaMail 创建一个邮件客户端。 我已成功收到电子邮件,并且大部分都已输入数据库。内容配置未正确输入数据库。 我在将内联对象导入数据库时​​遇到问题。

以下是我编写并在我的邮件客户端中实现的代码: **

String filename = part.getFileName();
File f = new File(filename);
InputStream in = new BufferedInputStream(part.getInputStream());
psINLINE.setBinaryStream(1, in);

收到以下错误代码:

java.sql.SQLException: Error reading from InputStream com.sun.mail.util.DecodingException
Caused by: com.sun.mail.util.DecodingException: BASE64Decoder: Error in encoded stream: needed at least 2 valid base64 characters, but only got 1 before padding character (=), the 10 most recent characters were: "%\164L\128\192<\160<\163="

这只发生在传入的 gmail 上。所有其他传入的邮件工作正常。 你能帮我解决这个问题吗?谢谢

【问题讨论】:

    标签: java email gmail jakarta-mail


    【解决方案1】:

    您使用的是什么版本的 JavaMail?

    protocol trace 显示什么?

    这通常只发生在消息格式或编码不正确时。

    【讨论】:

    • 感谢您的回复。 Im using JavaMail 1.5. I checked the log and it shows there is no problem, but if when the following code is reached a error arises : psINLINE.executeUpdate();`我不太确定你所说的协议跟踪是什么意思。我以为是日志。你能告诉我如何解决这个错误。任何反馈将不胜感激。
    • 你点击我上面的链接了吗?
    • 感谢您的链接。到达条件语句 System.setProperty("mail.mime.base64.ignoreerrors", "true") 后,com.sun.mail.util.DecodingException 没有错误。但是,当我检查协议跟踪时,编码图像的 base64 已损坏/乱码。我想将损坏的文本返回到 ASCII-TEXT。只有使用“Google 照片”功能的 gmail 才会出现这种情况。其他邮件客户端工作正常。在 google 更新此功能之前,我能够成功检索图像。
    • 好吧,也许你应该和谷歌谈谈?如果您需要帮助弄清楚发生了什么,请在此处发布协议跟踪,也许还附上演示问题的示例消息的副本。或者,通过 javamail_ww@oracle.com 将这些详细信息发送给我。
    猜你喜欢
    • 2010-11-19
    • 2015-08-18
    • 2012-08-30
    • 2012-05-20
    • 2012-03-03
    • 2010-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多