我有一个文本字段和一个按钮。当我输入数据并单击按钮时,它只添加一行。
public void widgetSelected(SelectionEvent e) {
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","nikshay");
Statement stmt=con.createStatement();
stmt.executeUpdate("create table sbase(person varchar(20),year number(2),gender varchar(1))");
PreparedStatement prepare=con.prepareStatement("insert into sbase (person,year,gender)values(?,?,?)");
prepare.setString(1,text.getText());
prepare.setString(2,text_1.getText());
prepare.setString(3,text_2.getText());
prepare.executeUpdate();
}
catch(Exception ex)
{
}
}
我应该怎么做才能添加多行。