有点急,在线等。以下是数据库里创建表的代码和源代码!麻烦各位姐妹哥弟康康我
数据表:
create table picture(pid int not null AUTO_INCREMENT primary key,img longblob not null,pname varchar(20),uploadtime varchar(30) not null,description varchar(50),type varchar(20),style varchar(20));
java程序:
public void actionPerformed(ActionEvent e) {
String selectsql="select * from picture where pname = ? and type = ? and style = ?;";
try {
Connection conn =DriverManager.getConnection("jdbc:mysql://localhost/mydatabase?serverTimezone=UTC","root","471414388");
PreparedStatement ps = conn.prepareStatement(selectsql);
ps.setString(1,textField.getText());
ps.setString(2,(String)comboBox.getSelectedItem());
ps.setString(3,(String)comboBox_1.getSelectedItem());
ResultSet rs = ps.executeQuery();
if(rs.next())System.out.print("yes");
while(rs.next()) {
FileInputStream in = (FileInputStream) rs.getBinaryStream("img");
FileOutputStream out = new FileOutputStream("./imgs/ttt.jpg");
System.out.print("yes");
byte[] b = new byte[in.available()];
in.read(b);
out.write(b);
in.close();
out.close();
}}
catch(Exception e1) {
e1.printStackTrace();
}
}