-1
These are the exceptions. jtableを作成しました。データは追加ボタンでテーブルに追加されました。送信ボタンを使用してデータベースに送信されます。ただし、送信ボタンコードがどこに間違っていたのか誰にでも教えてもらえますか? PreparedStatementのでOracle 11gデータベースにJtableデータを挿入する方法
btnSubmit.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
try {
int count = table.getRowCount();
String driver = "oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott", "tiger");
conn.setAutoCommit(false);
PreparedStatement pst = conn.prepareStatement("Insert into students(ROLL_NO,NAME,MID1,MID2,Marksinwords) values (?,?,?,?,?)");
for(int row = 0; row<count; row++)
{
String roll = (String)table.getValueAt(row, 0);
String name = (String)table.getValueAt(row, 1);
String MARKS1 = (String)tableModel.getValueAt(row, 2);
String MARKS2 = (String)table.getValueAt(row, 3);
String marksinwords = (String)table.getValueAt(row, 4);
pst.setString(1, roll);
pst.executeUpdate(roll);
pst.setString(2, name);
pst.executeUpdate(name);
pst.setString(3,MARKS1);
pst.executeUpdate(MARKS1);
pst.setString(4,MARKS2);
pst.executeUpdate(MARKS2);
pst.setString(5, marksinwords);
pst.executeUpdate(marksinwords);
pst.addBatch();
}
pst.executeBatch();
conn.commit();
} catch (Exception ex) {
Logger.getLogger(FacultyTableSubmit.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
例外を? – Marged
スクリーンショットを追加しました –
スクリーンショットとして例外を投稿しないでください。常にテキストを提示してください。あなたが幸運であれば、SOは自動的にあなたに、以前の投稿にすでに見つかっている例外を認識できる場合に、解決策を見つけることができる投稿を提案します。あなたの例外は完全には表示されていないのですが、それは – Marged