Java. SQL. sqlexception: [Microsoft] [ODBC Microsoft Access driver] Because duplicate values will be created in the index, primary keyword, or link, the requested changes to the table fail. Change the data in the field or field that contains duplicate data, delete the index or redefine the index to allow duplicate values and try again.
Public void actionreceivmed (actionevent e ){
// Todo auto-generated method stub
If (E. getsource () = jbt1)
{
Connection con = NULL;
Preparedstatement ST = NULL;
Resultset Re = NULL;
Try {
// Load the driver
Class. forname ("Sun. JDBC. ODBC. jdbcodbcdriver ");
// Get the connection (connect to the data source)
Con = drivermanager. getconnection ("JDBC: ODBC: studb ");
// Create a statement (send an SQL statement to obtain the database)
String stu1 = "insert into student1 values (?,?,?,?,?) ";
St = con. preparestatement (stu1 );
St. setstring (1, jtf1.gettext ());
St. setstring (2, jtf2.gettext ());
St. setstring (3, jtf3.gettext ());
St. setstring (4, jtf4.gettext ());
St. setstring (5, jtf5.gettext ());
St.exe cuteupdate ();
This. Dispose ();
} Catch (exception C)
{
C. printstacktrace ();
} Finally {
Try {
If (re! = NULL) Re. Close ();
If (st! = NULL) ST. Close ();
If (con! = NULL) con. Close ();
} Catch (exception C)
{
C. printstacktrace ();
}
}