我正在尝试将文件上传到oracle数据库但是我收到了这个错误:
java.sql.SQLException:ORA-01460:未实现或不合理 要求转换
这是我插入文件的代码:
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Connection conn;
FileInputStream fis = new FileInputStream(file);//From JFileChooser
String url = "*******************";
String u = "***********";
String p = "**********";
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url, u, p);
System.out.println("Ligação efectuada com sucesso");
PreparedStatement pstmt = conn.prepareStatement(
"insert into tableX(file, name) values ( ?, ?)");
pstmt.setString(2, file.getName());
pstmt.setBinaryStream(1, fis, (int) file.length());;
pstmt.executeUpdate();
JOptionPane.showMessageDialog(null, "Uploaded successfully to database");
pstmt.close();
conn.close();
} catch (Exception ex) {
System.out.println(ex);
}
}
});
文件来源来自JFileChooser
:
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
text.setText(file.getPath());
}
}
});
此错误是代码问题或来自Oracle JDBC driver
的问题?