请问代码报错怎么办
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 ");
}
}
谢谢