1. import java.sql.Connection;
    2. import java.sql.SQLException;
    3. /**
    4. * Function:
    5. * Time: 2021/10/29 13:43
    6. */
    7. public class JDBCTest {
    8. public static void main(String[] args) throws SQLException {
    9. Connection itcaststore = JDBCUtils.getConnection("itcaststore");
    10. int row = 0;
    11. try {
    12. row = itcaststore.prepareStatement(
    13. "insert into userinfor" +
    14. "(username, userpassword, gender, email, telephone)" +
    15. " VALUES ('陆俊','317499','男','3174919194','428912748')").executeUpdate();
    16. if (row>0){
    17. System.out.println("插入成功");
    18. }
    19. } catch (SQLException e) {
    20. System.out.println("插入失败");
    21. }
    22. }
    23. }

    可以对插入操作是否成功做出判断。