尝试将数据插入数据库。数据没有存储,我不明白这里有什么问题。
这些是要打印的错误消息的代码
System.out.println(e.getErrorCode());
System.out.println(e.getSQLState());
System.out.println(e.getMessage());
System.out.println(e.getCause());
System.out.println(e.getNextException());
控制台出错
Connection to SQLite has been established.
0
null
null
null
null
添加类以进一步了解详细信息。
CompanyDetailsController.java
@FXML
private void saveCompanyDetails(ActionEvent event) throws IOException {
String companyName = CompanyNameField.getText();
String details = detailsField.getText();
String address = addressField.getText();
String country = countryField.getValue().toString();
String city = cityField.getValue().toString();
String state = stateField.getValue().toString();
String stateCode = stateCodeField.getValue().toString();
String pin = pinField.getText();
String contactNumber = contactField.getText();
String email = emailField.getText();
String website = websiteField.getText();
String gstin = gstinField.getText();
String pan = panField.getText();
String tan = tanField.getText();
String taxtation = textationField.getValue().toString();
String taxRate = taxRateField.getText();
String proprietor = proprietorField.getText();
String aadhaar = aadhaarField.getText();
String currency = currencyField.getText();
String companyCode = companyCodeField.getText();
String pos = posField.getText();
fis= new FileInputStream(file);
String sql = "INSERT INTO companyDetails (companyName, additionalDetails, address, country, city, state, stateCode, pinCode, contactNumber,"
+ "email, website,GSTIN, TAN,PAN, taxationType, taxRate, proprietor,adhaarNo,currency,companyCode,POScode,logo,cid) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
try {
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, companyName);
pstmt.setString(2, details);
pstmt.setString(3, address);
pstmt.setString(4, country);
pstmt.setString(5, city);
pstmt.setString(6, state);
pstmt.setString(7, stateCode);
pstmt.setString(8, pin);
pstmt.setString(9, contactNumber);
pstmt.setString(10, email);
pstmt.setString(11, website);
pstmt.setString(12, gstin);
pstmt.setString(13, tan);
pstmt.setString(14, pan);
pstmt.setString(15, taxtation);
pstmt.setString(16, taxRate);
pstmt.setString(17, proprietor);
pstmt.setString(18, aadhaar);
pstmt.setString(19, currency);
pstmt.setString(20, companyCode);
pstmt.setString(21, pos);
pstmt.setBinaryStream(22,fis);
pstmt.executeUpdate();
hf.showDialog("Company Details Added Successfully");
} catch (SQLException e) {
System.out.println(e.getErrorCode());
System.out.println(e.getSQLState());
System.out.println(e.getMessage());
System.out.println(e.getCause());
System.out.println(e.getNextException());
}
}
有人可以帮忙吗?
最佳答案
您可以在 github 中找到不支持 JDBC v4,包括一些特殊的 setter,例如 BLOB、二进制类型...
public void setBinaryStream(int parameterIndex, InputStream x, long length)
throws SQLException {
// TODO Support this
throw new SQLFeatureNotSupportedException();
}
对于您在日志中遇到的问题,它正在使用 SQLFeatureNotSupportedException
没有参数的构造函数。医生说:
Constructs a SQLFeatureNotSupportedException object. The reason, SQLState are initialized to null and the vendor code is initialized to 0. The cause is not initialized, and may subsequently be initialized by a call to the Throwable.initCause(java.lang.Throwable) method.
关于java.sql.SQLFeatureNotSupportedException 在 org.sqlite.jdbc4.JDBC4PreparedStatement.setBinaryStream(JDBC4PreparedStatement.java :96),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48642263/