I hope all of you will take a look at this Java problem.

Source: Internet
Author: User
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 ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.