尝试在数据库中插入数据。数据没有存储,我不知道这里有什么问题。
这些是要打印的错误按摩代码
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());
}
}
任何人都可以帮忙吗?
答案 0 :(得分:2)
您可以在github中找到JDBC v4,包括一些特殊的setter,如BLOB,Binaries类型......,不支持
public void setBinaryStream(int parameterIndex, InputStream x, long length)
throws SQLException {
// TODO Support this
throw new SQLFeatureNotSupportedException();
}
对于日志中遇到的问题,它使用的SQLFeatureNotSupportedException
构造函数没有参数。医生说:
构造一个SQLFeatureNotSupportedException对象。 原因是,SQLState初始化为null,供应商代码初始化为0 。原因未初始化,随后可以通过调用Throwable.initCause(java.lang.Throwable)方法进行初始化。