List of usage examples for java.sql PreparedStatement executeUpdate
int executeUpdate(String sql) throws SQLException;
INSERT
, UPDATE
, or DELETE
statement or an SQL statement that returns nothing, such as an SQL DDL statement. From source file:com.fufang.testcase.his.GetMaterialContents.java
@BeforeTest public void insertSql() throws SQLException { SqlUtils c = new SqlUtils(); Con = c.mySqlConnection(dbUrl, dbUserName, dbPassword); String sql = "INSERT INTO `HISFC`.`t_community_contents` (`communityId`, `hisCode`, `contentsId`, `createDate`, `updateDate`) VALUES ('200301', 'J3001', 'a31cec32-d07c-4497-8841-fc864033676a', '2016-12-20 11:43:55', NULL);"; try {//from w ww . j a va2 s . co m PreparedStatement pstmt = Con.prepareStatement(sql); pstmt.executeUpdate(sql); sql = "INSERT INTO `HISFC`.`t_contents_item` (`contentsItemId`, `headId`, `headCode`, `ffId`, `name`, `materialType`, `commonName`, `licenseNum`, `manufName`, `unitName`, `spec`, `dosage`, `isDelete`, `createDate`, `updateDate`) VALUES ('031bbb2f-bda6-4c29-8e8a-c34e3cdca46d', 'a31cec32-d07c-4497-8841-fc864033676a', 'HYJ', '215911', '', 'Z', '', '?Z20093536', '???', '', '10*12', '', NULL, '2016-09-19 16:32:06', NULL);"; pstmt.executeUpdate(sql); sql = "INSERT INTO `HISFC`.`t_contents_item` (`contentsItemId`, `headId`, `headCode`, `ffId`, `name`, `materialType`, `commonName`, `licenseNum`, `manufName`, `unitName`, `spec`, `dosage`, `isDelete`, `createDate`, `updateDate`) VALUES ('03281538-cfc7-4917-a73f-e4cfe2dd9da6', 'a31cec32-d07c-4497-8841-fc864033676a', 'HYJ', '209247', '', 'Z', '', '?G20090276', '????', '', '0.25*300', '', NULL, '2016-09-19 16:29:39', NULL);"; pstmt.executeUpdate(sql); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (Con != null) Con.close(); } catch (SQLException se) { se.printStackTrace(); } } }