java

public static void main(String[] args) {
		Connection connection = DBConnection.getConn();
		Statement statement = null;
		ResultSet  resultSet = null;
		int rowCount ;
		try {
			 statement  =  connection.createStatement();
			 String sql = "insert into person(name,age,sex)   values('tom',15,'男')";  
			 rowCount = statement.executeUpdate(sql);
			 System.out.println("插入所影响的行数为"+rowCount+"行");
			} catch (SQLException e) {
				e.printStackTrace();
		}finally{
			DBConnection.close(connection, statement, resultSet);
			}
		}
	}
 

你可能感兴趣的:(java,sql)