javaworld123 2022-07-23 17:06 采纳率: 40%
浏览 54

JavaMySQL报错

请问代码报错怎么办
Exception in thread "main" java.sql.SQLSyntaxErrorException: Table 'java.pic' doesn't exist
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1009)
at 测试.file.main(file.java:13)

package 测试;
import java.io.*;
import java.sql.*;
class file {
    public static void main(String[] args) throws Exception {
        InputStream is = null;
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/java","root", "xxx");
        byte[] buffer = new byte[4096];
        FileOutputStream outputImage = null;
        PreparedStatement ps = con.prepareStatement("select img from pic where a=?");
        ps.setString(1, "1");
        ResultSet rs = ps.executeQuery();//java.pic
        rs.next();
        File file = new File("D:/1.png");
        if (!file.exists()) {
            file.createNewFile();           
          }
          outputImage = new FileOutputStream(file);                           
            Blob blob = rs.getBlob("b");   
            is = blob.getBinaryStream();           
            int size = 0;        
            while ((size = is.read(buffer)) != -1) {           
                outputImage.write(buffer, 0, size);            
            }
            System.out.println("file read success ");
    }
}

谢谢

  • 写回答

1条回答 默认 最新

  • 农居诗人 2022-07-23 17:14
    关注

    Table 'java.pic' doesn't exist**(java.pic表格不存在)**
    检查一下mysql中 java库中是否存在pic这张表

    评论

报告相同问题?

问题事件

  • 修改了问题 7月23日
  • 创建了问题 7月23日

悬赏问题

  • ¥15 python使用selenium工具爬取网站的问题
  • ¥15 visual studio中c语言用ODBC链接SQL SERVER
  • ¥15 关于#python#的问题:如何通过pywinauto获取到图中“窗格”内部的内容
  • ¥15 visionMaster4.3.0 与QT 的二次开发异常
  • ¥50 关于#pcb工艺#的问题:这个设计电路中,最终组合起来起到了什么作用
  • ¥15 鼎捷t100或鼎捷E10生产模块与odoo17详细区别和鼎捷t100或鼎捷E10物料清单(BOM)可以在子级的子级在同一界面操作吗
  • ¥50 VS2019,xamarin框架串口调试报错Java.Lang.SecurityException: Exception of type
  • ¥20 QT如何判断QLineF线鼠标划过事件
  • ¥15 关于#phpstorm#的问题:phpstorm编辑工具 光标选中了就会自动复制到粘贴板上 这样我之前复制的内容就失效了
  • ¥15 pychram安装jupyter插件