私は Java データベースの初心者ですが、誰でもこの問題を解決できます..ms アクセス ファイルの行を編集したいのですが、「java.lang.NullPointerException」エラーが発生します..ありがとう
これが私のコードです...
public void editBook(String inputTitle, String[] newBookInfo)
{
boolean result = false;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:database");
st = con.createStatement();
rs = st.executeQuery("select * from library");
while(rs.next())
{
if(boyerMoore(rs.getString("Title"), inputTitle))
{
rs.updateString("ISBN", newBookInfo[0]);
rs.updateString("Title", newBookInfo[1]);
rs.updateString("Author", newBookInfo[2]);
rs.updateString("Publisher", newBookInfo[3]);
rs.updateString("Published Year", newBookInfo[4]);
rs.updateString("Available Copies", newBookInfo[5]);
rs.updateString("Total Copies", newBookInfo[6]);
rs.updateRow();
rs.close();
st.close();
con.close();
JOptionPane.showMessageDialog(null, "Edit Succes", "Succes", JOptionPane.PLAIN_MESSAGE);
result = true;
}
}
if(!result)
JOptionPane.showMessageDialog(null, "\"" + inputTitle + "\" not Found in the Library", "Error", JOptionPane.ERROR_MESSAGE);
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null, ex, "Error", JOptionPane.ERROR_MESSAGE);
}
}