-1
These are the exceptions.我们创建了一个jtable,通过添加按钮将数据添加到表中,并通过提交按钮将数据发送到数据库。但是当提交按钮被点击。谁能告诉我代码出错的地方?如何在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