这是我的代码:
{
try
{
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection con=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\MUHAMMAD SHAHAB\\real estate.accdb");
String username=shah.getText();
String password=String.valueOf(jd.getPassword());
String address=haf.getText();
String mobile=mensa.getText();
String email=text.getText();
String role= misa.getText();
String country=unity.getText();
String city=cety.getText();
String company=milan.getText();
PreparedStatement pst;
pst=con.prepareStatement("INSERT INTO simba (Username,Password,Address,Mobile No,Email Address,Role,Country,City,Company)"+"values(?,?,?,?,?,?,?,?,?)");
pst.setString(1,username);
pst.setString(2,password);
pst.setString(3,address);
pst.setString(4,mobile);
pst.setString(5,email);
pst.setString(6,role);
pst.setString(7,country);
pst.setString(8,city);
pst.setString(9,company);
int i=pst.executeUpdate();
if(i>0)
{
JOptionPane.showMessageDialog(null,"data is saved");
}
else
{
JOptionPane.showMessageDialog(null,"data is not saved");
}
}
catch (Exception ex) {
JOptionPane.showMessageDialog(null,ex);
}
}
});
我正在尝试在ms访问数据库when i run the progrom i got the following messsage中的八列中插入数据。 我的ms访问表MY Ms access table 我做错了什么
答案 0 :(得分:0)
你需要一些括号:
pst=con.prepareStatement("INSERT INTO simba (Username,[Password],Address,[Mobile No],[Email Address],Company)"+"values(?,?,?,?,?,?)");